MLH wrote:
I would appreciate seeing a solution I might adapt
to an A97 platform with some minor mods.
>>Did the responses provide you with a solution? If not, I'll post one
for you.
I have an unbound form (I can pass the initial data to) with the
following fields; Address, State, City, Zip and the command button
DisplayMap. I had read a post about a year+ indicating how to do it in
this newsgroup and I modified it for my needs.
Private Sub CommandDisplayM ap_Click()
On Error GoTo Err_CommandFind Address_Click
If Not IsNull(Me.City) And Not IsNull(Me.State ) Then
'Declare variables.
Dim strURL As String
Dim objBrowser As Object
'create the string to pass to google maps
strURL = CreateUrl()
strURL = "http://maps.google.com/maps?q=" & strURL &
"&iwloc=A&hl=en "
Dim obj As Object
Set obj = CreateObject("I nternetExplorer .Application")
With obj
.Navigate2 strURL
.Visible = True
End With
Set obj = Nothing
Else
MsgBox "You need to supply at least the city and state.", ,
"Missing Info"
End If
Exit_CommandDis playMap_Click:
Exit Sub
Err_CommandDisp layMap_Click:
MsgBox Err.Description
Resume Exit_CommandDis playMap_Click
End Sub
Private Function CreateUrl() As String
'generate the URL to pass to Google in browser.
Dim strURL As String
Dim strOrig As String
Dim intPos As Integer
If Not IsNull(Me.Addre ss) Then
'parse out the address elements. Ex:
'123 Somewhere St = 123+Somewhere+S t
strOrig = Me.Address
Do While True
If strOrig <"" Then
intPos = InStr(strOrig, " ")
If intPos 0 Then
strURL = strURL & Left(strOrig, intPos - 1) & "+"
strOrig = LTrim(Mid(strOr ig, intPos + 1))
Else
strURL = strURL & strOrig & "+"
Exit Do
End If
Else
Exit Do
End If
Loop
End If
strURL = strURL & Me.City & "+" & Me.State & "+"
If Not IsNull(Me.ZipCo de) Then strURL = strURL & Me.ZipCode & "+"
CreateUrl = Left(strURL, Len(strURL) - 1)
End Function