ScrmingWhisprs
I <3 Coffee Milk.
- Local time
- Today, 02:00
- Joined
- Jun 29, 2006
- Messages
- 156
I am attempting to use 2 fields from a query to supply the Top and Left Properties of a Collection of Rectangle Controls on my form. The purpose of this is to display the locations on a map of "Spots" in a haunted house I help run. The query that I am using shows the spots that have been pre-tagged with the location of where they belong on the map (currently the query has only 24 tagged spots). On the actual form I have rectangle controls (control type acRectangle) with their visible property set to False by default, named box1 through box25 (there will be more eventually, as I am just working with this test group).
I started with the following code, yet it stops after (correctly) placing the first spot on the map (please see the attached jpg):
I'm sure I need to have 'Loop' in there somewhere, but I am not sure exactly where to place it, or if another line is also needed.
Thanks ahead of time!
Mike
I started with the following code, yet it stops after (correctly) placing the first spot on the map (please see the attached jpg):
Code:
Private Sub Form_Open(Cancel As Integer)
Dim ctl As Control
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT qrySpotMap.Spot, qrySpotMap.MAPX, qrySpotMap.MAPY FROM qrySpotMap"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
For Each ctl In Me.Controls
If ctl.ControlType = acRectangle Then
rst.MoveFirst
ctl.Left = rst.Fields("MAPX")
ctl.Top = rst.Fields("MAPY")
ctl.Visible = True
End If
rst.MoveNext
Next ctl
Set rst = Nothing
Set db = Nothing
End Sub
I'm sure I need to have 'Loop' in there somewhere, but I am not sure exactly where to place it, or if another line is also needed.
Thanks ahead of time!
Mike