How can I parse or Loop a list based on single field to Googlemaps

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is some code that will parse each sequential field [Point_#) into a list
for googlemaps.

[Form_Runs].WebRouteMap.navigate
"http://maps.google.co.uk/maps?f=q&hl=en&q=" & "from: " & Me.Point_1 & (" to:
" + Me.Point_2) & (" to: " + Me.Point_3)

The table/form is laid outlike this:

[Route_No] [Point_1] [Point_2] [Point_2]
5 North St, N1 East St, N3 High Road, W6

And the code will give this style of parsed list:
from: North St, N1 to: East St, N3 to: High Road, W6


That works just fine for a finite number of separate fields, but I need to
achieve the same thing for a single field, but with sequential records of
data. The number of records (addresseses) will differ from main record to
record, some routes are just a few addresesses, while others can be upto 12
addresses, so I need the code to go through each record and sequentialy add
the data to the parsed list ready for Googlemaps; bearing in mind that each
list will be a different number of records. Does anyone know how I can do
this with code?


The table/form is laid outlike this:

[Route_No] [Run_waypoint]

5 North St, N1
5 East St, N3
5 High Road, W6
 
You need to loop through your recordset, comparing the current RouteNo with
the previous RouteNo. Keep appending the Waypoints until the Route No
changes.

Here is some approximate (untested) code:

Set rsRouteWaypoint = CurrentDB().OpenRecordset("RouteWaypoint")
With rsRouteWaypoint
.MoveFirst
strHoldRoute=![RouteNumber]
strOut=![WayPoint]

Do While Not .EOF
strRoute=![RouteNumber]
If strRoute<>strHoldRoute then
debug.print strOut
strHoldRoute = strRoute
strOut= ![WayPoint]
Else
strOut=strOut & " to: " & ![WayPoint]
End If
.MoveNext
Loop
End With 'rsRouteWaypoint
 
Hi Margaret,

I broadly follow your suggestion, but am a little confused and unsure of how
or where the data outputs, does it go to a table or direct to the browser
like my example ( "http://maps.google.co.uk/maps?f=q&hl=en&q=" & "from: " &
Me.Point_1 & (" to: " + Me.Point_2) & (" to: " + Me.Point_3) does?.

Also, are you using the syntax "RouteWaypoint" for my [Run_waypoint]?
and is your [RouteNumber] the eqivelant of my [Run_No]?.



MargaretBartley said:
You need to loop through your recordset, comparing the current RouteNo with
the previous RouteNo. Keep appending the Waypoints until the Route No
changes.

Here is some approximate (untested) code:

Set rsRouteWaypoint = CurrentDB().OpenRecordset("RouteWaypoint")
With rsRouteWaypoint
.MoveFirst
strHoldRoute=![RouteNumber]
strOut=![WayPoint]

Do While Not .EOF
strRoute=![RouteNumber]
If strRoute<>strHoldRoute then
debug.print strOut
strHoldRoute = strRoute
strOut= ![WayPoint]
Else
strOut=strOut & " to: " & ![WayPoint]
End If
.MoveNext
Loop
End With 'rsRouteWaypoint


efandango said:
This is some code that will parse each sequential field [Point_#) into a list
for googlemaps.

[Form_Runs].WebRouteMap.navigate
"http://maps.google.co.uk/maps?f=q&hl=en&q=" & "from: " & Me.Point_1 & (" to:
" + Me.Point_2) & (" to: " + Me.Point_3)

The table/form is laid outlike this:

[Route_No] [Point_1] [Point_2] [Point_2]
5 North St, N1 East St, N3 High Road, W6

And the code will give this style of parsed list:
from: North St, N1 to: East St, N3 to: High Road, W6


That works just fine for a finite number of separate fields, but I need to
achieve the same thing for a single field, but with sequential records of
data. The number of records (addresseses) will differ from main record to
record, some routes are just a few addresesses, while others can be upto 12
addresses, so I need the code to go through each record and sequentialy add
the data to the parsed list ready for Googlemaps; bearing in mind that each
list will be a different number of records. Does anyone know how I can do
this with code?


The table/form is laid outlike this:

[Route_No] [Run_waypoint]

5 North St, N1
5 East St, N3
5 High Road, W6
 
Back
Top