Access Address and Google Maps

A

AJ

I feel like I'm so close... but so far with this.

I have the following code for On Click.

Private Sub GrabMap_Click()
Dim strLinkPath As String
Dim strExtra As String

strLinkPath = "http://maps.google.com/maps?q="
strExtraInfo = "me.Address+me.City+me.State+me.ZipCode"
Application.FollowHyperlink Address:=strLinkPath,
extrainfo:=strExtra, NewWindow:=True
End Sub

When clicked, I get the following:

http://maps.google.com/maps?q=?

Any ideas? I appreciate all input!
 
D

Douglas J Steele

I'm assuming Address, City, State and ZipCode are fields on your form. To
get their values into strExtraInfo (as opposed to the literal
"me.Address+me.City+me.State+me.ZipCode", try:

strExtraInfo = me.Address & "+" & me.City & "+" & _
me.State & "+" & me.ZipCode

I suspect, though, that you're going to need to replace any spaces in those
fields with %20, in order to have a valid URL, so try:

strExtraInfo = Replace(me.Address, " ", "%20") & "+" & _
Replace(me.City, " ", "%20") & "+" & _
me.State & "+" & me.ZipCode
 
A

AJ

This is probably a "dirty" way or something... I don't know. But this
works:

strExtra = Replace(Me.Address, " ", "%20") & "+" & Replace(Me.City,
" ", "%20") & "+" & Me.State & "+" & Me.ZipCode & "+"


It adds a ? to the beginning... but Google Maps doesn't seem to care.
 
A

AJ

Sorry for the string of posts by me. There's been another update.

Is there a way to "strip" # signs and such? Addresses such as 6329-I
Newberry Road #A3B get rejected by Google.
 
D

Douglas J Steele

If all you need to do is remove the # sign, use Replace(string, "#", "")

If you need to substitute something else for the #, I suspect it'll be %23.
 
A

AJ

Thanks... but how do you put multiple replaces together? I already
have:

Replace(Me.Address, " ", "%20")

Thanks!
 
A

AJ

Actually, I got this to work:

Dim strLinkPath As String
Dim strExtra As String

strLinkPath = "http://maps.google.com/maps?f=q&hl=en&q="
NewAddress = Replace(Me.Address, "#", "%23")
strExtra = Replace(NewAddress, " ", "%20") & "+" & Replace(Me.City,
" ", "%20") & "+" & Me.State & "+" & Me.ZipCode & "+"
Application.FollowHyperlink Address:=strLinkPath,
extrainfo:=strExtra, NewWindow:=True
 
T

t568aort568b

I know it is not google maps but this is what I use.
strAdd = Me.Address
strZip = Me.Zip_Code
strMap = "http://maps.msn.com/home.aspx?strt1=" & strAdd &
"&zipc1=" & strZip & "&cnty1=0"
Application.FollowHyperlink strMap

No need for anything but the street and the zip.
 

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