By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

Click on Map area to chose filter for Query

P: n/a
Hi all, i am a newbie trying to have a map of South Africa with the
various Provinces (States) and want to click on one and them to open a
report for that selection, using the clicked area as the filter criteria
for the query, or must one make a query for each province ??

Thanks in advance for any help

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Nov 30 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Wed, 30 Nov 2005 10:03:11 GMT, Les Stout <an*******@devdex.com>
wrote:

You'll want to use what the help file and all the books call a
"parameter query".
To find out what province was clicked, perhaps each can have a
different color. There are ways to get the color of the pixel that was
clicked, e.g. there is a Windows API that can do this (sorry I forgot
the name).

-Tom.

Hi all, i am a newbie trying to have a map of South Africa with the
various Provinces (States) and want to click on one and them to open a
report for that selection, using the clicked area as the filter criteria
for the query, or must one make a query for each province ??

Thanks in advance for any help

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


Nov 30 '05 #2

P: n/a

"Tom van Stiphout" <no*************@cox.net> schreef in bericht news:26********************************@4ax.com...
On Wed, 30 Nov 2005 10:03:11 GMT, Les Stout <an*******@devdex.com>
wrote: To find out what province was clicked, perhaps each can have a
different color. There are ways to get the color of the pixel that was
clicked, e.g. there is a Windows API that can do this (sorry I forgot
the name).


Another approach (no API's needed) would be to use invisible controls at the image of the map.
I have seen a similar case implemented that way once.

For some country's you will need several controls to 'get it covered'.
When a naming-convention is used for the controls, you are able to call a generic function to do what you want when a control is clicked.
(use Screen.ActiveControl.Name in the function)

Maybe the country's have ID's like 1, 2 , 3 ,4 x x x x x
Name your controls like 1Ctrl1, 1Ctrl2, 1Ctrl3 these are the controls behind (before) Country1
(3 controls needed to cover the country1)
Name your controls like 2Ctrl1, 2Ctrl2, these are the controls behind (before) Country2
(2 controls needed to cover the country2)

You get the idea I hope?

Arno R

Nov 30 '05 #3

P: n/a
Tom van Stiphout wrote:
On Wed, 30 Nov 2005 10:03:11 GMT, Les Stout <an*******@devdex.com>
wrote:

You'll want to use what the help file and all the books call a
"parameter query".
To find out what province was clicked, perhaps each can have a
different color. There are ways to get the color of the pixel that was
clicked, e.g. there is a Windows API that can do this (sorry I forgot
the name).

-Tom.


I like Tom's idea. If you can find the API function to return the
pixel information it would be a very elegant solution to the problem.
Maybe:

Private Declare Function GetPixel Lib "gdi32.dll" (ByVal hdc As Long,
ByVal x As Long, ByVal y As Long) As Long

It is rumored that a call to GetDeviceCaps can determine whether or not
GetPixel can be used on a particular device.

If not, I have not yet proven the following but it's the best my
intuition can do at the moment. Also, I believe that some graphics
books show some standard methods for determining whether or not a point
is in a region bounded by line segments. Note that HTML has this
capability built-in :-).

Assuming the region is a simple polygon (possibly concave in places),
make a table that consists of the point coordinates of the polygon in
order, say counterclockwise (CCW). It should look something like:

tblBoundaries
BID Autonumber Primary Key
ProvinceID Long Foreign Key
VertexID Long
VX Long (Twips)
VY Long (Twips)

I am assuming you are getting X and Y from the MouseDown event (perhaps
Detail_MouseDown). X is positive to the right and Y is positive down.
Let the envelope region of a line segment be defined as the region
swept out by the line segment along its normal in both directions. If
the point that was clicked does not lie in any of the envelopes of its
boundary then it must lie outside the region. Of the boundary segments
whose envelope contains the point find the closest one. Decide what
you want to do if a point on the vertex or boundary is chosen. If CCW
was chosen, the point is interior if it lies to the left when going
from the smaller numbered vertex to the larger (except for N back to
1). I believe the distance (or its square for simplicity) from a point
to a line as well as an envelope test done by seeing if the point lies
within two lines can be improved using vector math (directed line
segments correspond 1-1 with vectors). Until a region is found, the
code would need to loop through each ProvinceID. I'm guessing that a
public function utilizing recordsets will be needed to implement
obtaining the ProvinceID, if any, of the location clicked. When you
can obtain the ProvinceID you can use a single report that covers any
province. As you can see, this method involves a lot more work than
using Tom's idea even if you cut some corners (literally :-)). Post
back if you'd like me to explore this idea further.

James A. Fortune

Dec 1 '05 #4

P: n/a
Thank you all for the input, will bash on with it. Sorry for the time
delay due different time zones..

best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Dec 1 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.