Need help for code to generate spots on map

kenpachi

New member
Local time
Today, 18:22
Joined
Dec 18, 2008
Messages
6
Here is my ruff around the edges code to generate spot on a report with the background as a picture of a map.

The coordinates are GPS, the positions are between the upper left corner and lower right corner of the picture (georeferenced).

What I need to do is loop trough each records to get the values for positioning the circles and text on the map. The data come from a query where the catégories of clients is selected.

Thank you in advance


Private Sub Report_Page()

‘Variables and constants for Circle - (Circle Method)
Const conPI = 3.14159265359
Dim sngHCtr As Single, sngVCtr As Single
Dim sngRadius As Single
Dim sngStart As Single, sngEnd As Single

‘Variables for Text over the circles - (Print method)
Dim rpt as ReportDim strMessage As StringDim intHorSize As Integer, intVerSize As Integer

‘Variables for DAO


‘Variables for Loop


Query = “DataXY “
Fields = [Number],[ColorCode],[dX] and [dY]
Label = [Number] ‘Number that Id the circle
ValColor = [ColorCode] ‘ Value of the color of the circle
X = [dX] ‘Coordinate X (position text on map)
Y = [dY] ‘Coordinate Y (position text on map)

For each record in query

Do While not EOF
‘Draw Circle
sngHCtr = X ' Horizontal position.
sngVCtr = Y ' Vertical position.
sngRadius = Me.ScaleHeight / 100 ' Circle radius.
Me.Circle (sngHCtr, sngVCtr), sngRadius ‘Draw Circle
sngStart = -0.00000001 ' Start of pie slice.
sngEnd = -256 * conPI / 129 ' End of pie slice.
Me.FillColor = ValColor ' Color pie slice.
Me.FillStyle = 0 ' Fill pie slice.
Me.ForeColor = ValColor
' Draw pie slice within circle.
Me.Circle (sngHCtr, sngVCtr), sngRadius, , sngStart, sngEnd

‘Draw Text over circle
Set rpt = Me strMessage = Label With rpt 'Set scale to pixels, and set FontName and 'FontSize properties. .ScaleMode = 3 .FontName = "Courier" .FontSize =6 .ForeColor = ValColor .FontBold = 1 End With ' Horizontal width. intHorSize = Rpt.TextWidth(strMessage) ' Vertical height. intVerSize = Rpt.TextHeight(strMessage) ' Calculate location of text to be displayed. Rpt.CurrentX = X - (intHorSize/2) Rpt.CurrentY = Y - (intVerSize/2) ' Print text on Report object. Rpt.Print strMessage

End for


End Sub
 
From memory (and without having access to Access at the moment) - using the report object's drawing methods won't show up on top of the picture. They print below the picture object and you can't see them. I could be wrong though.

However - with regards to your actual question. I'd have the report being unbound (no data source), and use a recordset to loop through instead, using the On Print or On Format event of the report.

Pete
 
For the picture I moved it to the back the circle and print function works and are in front of the picture.

The problem lie more about the ADO recordset and the loop itself. That's where I need some help.
 
Not sure the problem. I don't use much Dao but I imagine there are plenty of examples out there on the net. I'm guessing something like this:

Dim RS As DAO.Recordset
Set rs = CurrentDB.OpenRecordSet(stringQuery)

or maybe this:

Dim RS As DAO.Recordset
Dim qDef as Dao.QueryDEf
Set qDef = CurrentDb.QueryDefs("qryCoordinates")
Set rs = qDef.OpenRecordset

and then loop through the rs:

Do While not rs.Eof
'assuming you have an x-Coordinate column
Dim x as Long
x = rs("xCoordinate")
rs.MoveNext
Loop

Where exactly are you having the problem?




 
Oh, I thought you wanted DAO. With ADO:

Dim rs as New ADODB.Recordset
rs.Open "SELECT * FROM tblCoordinates", CurrentProject.Connection

Or maybe

rs.Open "qryCoordinates", CurrrentProject.Connection
 
And don't forget:

rs.Close
set rs = nothing

after the loop.
 
Ok thanks jal

About the loop thing I did try something like this:

For each record do circle and text

end for

I'm having difficulties about passing the arguments in the loop
 
Ok thanks jal

About the loop thing I did try something like this:

For each record do circle and text

end for

I'm having difficulties about passing the arguments in the loop
Hmm...Passing arguments from within a loop should be pretty much the same as doing it outside the loop. Care to be more specific as to the problem?
 

Users who are viewing this thread

Back
Top Bottom