Google Map

D

David Plotts

Right now I have a form with addresses and want to be able to get a google
map from it. How do I go about doing so?

Right now I have 4 fields for the address: street, city, state, zip
 
I

IanOxon via AccessMonster.com

Hi David,

If you do a google map search for a place and it generates a valid location,
you can get a link to it in the browser address. For example: Riverside
California 92504 would generate the following link :
http://maps.google.com/maps?f=q&hl=en&q=Riverside+California+92504

So you could use your address record field data to construct a URL like this
"http://maps.google.com/maps?f=q&hl=en&q=" & [street] & "+" & [city] & "+" &
[state] & "+" & [zip]

If you want the results displayed on the address form you'll have to add the
Microsoft Web Browser ActiveX control to it. You can use the forms OnCurrent
event to display the results in the Web Browser control:

Private Sub Form_Current()
On Error GoTo Err_Form_Current
Dim strURL As String

strURL = "http://maps.google.com" ' or other default web page.
If Not NewRecord Then
With Me
'strURL = "http://maps.google.com/maps?f=q&hl=en&q=" & ![street]
& "+" & ![city] & "+" & ![State] & "+" & ![zip]
End With
End If
ctlWebBrowser.Navigate strURL

Exit_Form_Current:
Exit Sub

Err_Form_Current:
MsgBox Name & "_Current Error: " & Err.Number & ": " & Err.Description
Resume Exit_Form_Current
End Sub

If the Web Browser Control doesn't appear in youlist of ActiveX controls
you'll have to install Microsoft Internet Controls Library SHDocVw (it'll
then appear in C:\WINDOWS\System32\shdocvw.dll or similar).


Regards


Ian
 
D

David Plotts

I just want to be able to have a hyperlink or button on the form. It would
have to be with:

http://maps.google.com/maps?f=q&hl=en&q= &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_Street] & " +" &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_City] & "+" &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_State] & "+" &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_Zip]

When I create I hyperlink with that I get

http://maps.google.com/maps?f=q&hl=en&q= & [BUSINESS_PHYSICAL_ADDRESS_T]![BP_Street] & "%20+"%20%20&%20%20[BUSINESS_PHYSICAL_ADDRESS_T]![BP_City]%20&%20%20"+"%20&%20[BUSINESS_PHYSICAL_ADDRESS_T]![BP_State]%20%20%20&%20%20"+"%20&%20[BUSINESS_PHYSICAL_ADDRESS_T]![BP_Zip]

How do I set this up correctly?

Thanks

David



IanOxon via AccessMonster.com said:
Hi David,

If you do a google map search for a place and it generates a valid
location,
you can get a link to it in the browser address. For example: Riverside
California 92504 would generate the following link :
http://maps.google.com/maps?f=q&hl=en&q=Riverside+California+92504

So you could use your address record field data to construct a URL like
this
"http://maps.google.com/maps?f=q&hl=en&q=" & [street] & "+" & [city] & "+"
&
[state] & "+" & [zip]

If you want the results displayed on the address form you'll have to add
the
Microsoft Web Browser ActiveX control to it. You can use the forms
OnCurrent
event to display the results in the Web Browser control:

Private Sub Form_Current()
On Error GoTo Err_Form_Current
Dim strURL As String

strURL = "http://maps.google.com" ' or other default web page.
If Not NewRecord Then
With Me
'strURL = "http://maps.google.com/maps?f=q&hl=en&q=" &
![street]
& "+" & ![city] & "+" & ![State] & "+" & ![zip]
End With
End If
ctlWebBrowser.Navigate strURL

Exit_Form_Current:
Exit Sub

Err_Form_Current:
MsgBox Name & "_Current Error: " & Err.Number & ": " & Err.Description
Resume Exit_Form_Current
End Sub

If the Web Browser Control doesn't appear in youlist of ActiveX controls
you'll have to install Microsoft Internet Controls Library SHDocVw (it'll
then appear in C:\WINDOWS\System32\shdocvw.dll or similar).


Regards


Ian

David said:
Right now I have a form with addresses and want to be able to get a google
map from it. How do I go about doing so?

Right now I have 4 fields for the address: street, city, state, zip
 
I

IanOxon via AccessMonster.com

Hello again David,

Space characters are replaced by "%20" when the URL string is loaded into the
browser. The example I gave you assumed you had valid field values i.e. non-
null, non-zero length strings with no leading and trailing spaces. Sorry
about this oversight.

OK, I'd suggest you use a CommandButton, cmdHyperlink which can be disabled.
The Form_Current Event to set the HyperlinkAddress properties of either like
this:

Private Sub Form_Current()
On Error GoTo Err_Form_Current
Dim strQuery As String
Dim intField As Integer

cmdHyperlink.HyperlinkAddress = ""
If Not NewRecord Then
ReDim arr(3) As Variant
With Me
arr(0) = ![BP_Street]
arr(1) = ![BP_City]
arr(2) = ![BP_State]
arr(3) = ![BP_Zip]
End With
For intField = 0 To UBound(arr)
If Not IsNull(arr(intField)) Then
arr(intField) = Trim(arr(intField)) 'Leading & trailing
spaces removed.
If Not arr(intField) = "" Then 'Only non zero-length strings
used to build strQuery.
If strQuery = "" Then
strQuery = arr(intField)
Else
strQuery = strQuery & "+" & arr(intField)
End If
End If
End If
Next intField
If Not strQuery = "" Then 'If valid strQuery then construct non-
default URL
cmdHyperlink.HyperlinkAddress = "
http://maps.google.com/maps?f=q&hl=en&q=" & strQuery
End If
End If
With cmdHyperlink
.Enabled = Not (.HyperlinkAddress = "")
End With

Exit_Form_Current:
Exit Sub

Err_Form_Current:
MsgBox Name & "_Current Error: " & Err.Number & ": " & Err.Description
Resume Exit_Form_Current
End Sub

The cmdHyperlink.Caption property value can also be generated in the same
procedure.

This will only be as good as the data that Users enter. Simple trmimming
could be added in the AfterUpdate Events of the Address Controls:

Privater Sub AddressControl_AfterUpdate()
Dim strValue as String

strValue =Trim(AddressControl)
If strValue ="" Then
AddressControl = Null
Else
AddressControl = strValue
End If
End Sub

Any other probs, give me a shout.

Ian

David said:
I just want to be able to have a hyperlink or button on the form. It would
have to be with:

http://maps.google.com/maps?f=q&hl=en&q= &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_Street] & " +" &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_City] & "+" &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_State] & "+" &
[BUSINESS_PHYSICAL_ADDRESS_T]![BP_Zip]

When I create I hyperlink with that I get

http://maps.google.com/maps?f=q&hl=en&q= & [BUSINESS_PHYSICAL_ADDRESS_T]![BP_Street] & "%20+"%20%20&%20%20[BUSINESS_PHYSICAL_ADDRESS_T]![BP_City]%20&%20%20"+"%20&%20[BUSINESS_PHYSICAL_ADDRESS_T]![BP_State]%20%20%20&%20%20"+"%20&%20[BUSINESS_PHYSICAL_ADDRESS_T]![BP_Zip]

How do I set this up correctly?

Thanks

David
Hi David,
[quoted text clipped - 50 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top