Add a Google Map button to an Access form

I am trying to add a button my my Access form that takes an address from form fields and brings up a Google map of that address. I have been searching online and only find references that are many years old. Below is what I am trying but it doesn't bring up the address. Only google Maps for my current location.

any help would be greatly appreciated. - Thank You

Dim straddress As String
Dim strlink As String
Dim strstate As String

On Error GoTo myErr
strstate = "New York"

straddress = Forms![selected properties1].address & "+" & Forms![selected properties1].borough & "+" & strstate & "+" & Forms![selected properties1].Zip
strlink = "http://maps.google.com/maps?q=" & straddress
Application.FollowHyperlink strlink

On Error GoTo 0
    Exit Sub

myErr:
    Resume Next
LVL 1
Robert WardlowPresidentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
Robert

I can't really see anything wrong with that code.

What happens if you remove the On Error Resume Next?
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
hi Robert,

if you are in the code behind the form, you can use Me. instead of Forms![selected properties1]

space between info will be changed to +, but it will still render

'180131 strive4peace
'Google Map
   Dim vAddress As Variant _
      , sDelimiter As String _
      , sURL As String

   vAddress =null

   With Me.address 
      If Not IsNull(.Value) Then
         vAddress = (vAddress + " ") & .Value
      End If
   End With

   With Me.borough 
      If Not IsNull(.Value) Then
         vAddress = (vAddress + " ") & .Value & " NY" 'automatically add NY
      End If
   End With

'   With Me.State
'      If Not IsNull(.Value) Then
'         vAddress = (vAddress + " ") & .Value
'      End If
'   End With
   With Me.Zip
      If Not IsNull(.Value) Then
         vAddress = (vAddress + " ") & .Value
      End If
   End With

   sURL = "https://maps.google.com/maps?q=" & vAddress
   Application.FollowHyperlink sURL

Open in new window

have an awesome day,
crystal
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
Not sure, but I think you are using an old search string

Here is what Google maps seems to be using now:

    https://www.google.com/maps/place/10+David+St,+Holbrook,+NY+11741

This translates to six parameters:
    StreetNumber+StreetName+StreetDesignation+Town+State+Zip

So I create "All six" textboxes and fill them all in (except for the state, ..since that is a variable in your code)
...and this code works fine for me:

Dim straddress As String
Dim strlink As String
Dim strstate As String

strstate = "New York"

    straddress = Me.StreetNumber & "+" & Me.SteetName & "+" & Me.StreetDesignation & "+" & Me.Town & "+" & strstate & "+" & Me.zip
    strlink = "https://www.google.com/maps/place/" & straddress
    Application.FollowHyperlink strlink

Open in new window

0
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
adding on ... Google will change space to plus, and it is so much easier to specify space!
0
Robert WardlowPresidentAuthor Commented:
Thank you Crystal, this is the perfect solution for my problem.
1
Robert WardlowPresidentAuthor Commented:
Thank you for your help Jeffrey. I would have had to find a way to separate the Street, Road, Blvd, out of the address.
I appreciate your help
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome, Robert ~ happy to help
0
Robert WardlowPresidentAuthor Commented:
Thank you Norie, I don't think the On Error was my problem. It seems the syntax for Google changed.
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
fwiw, I suspect that the problem with your original code was that it might generate 2 or more "+" in a row if something was blank. The syntax did not change... I stumbled on the automatic correction of space to +
0
Robert WardlowPresidentAuthor Commented:
Thanks, I was testing with an address where none of the fields were blank and it still didn't work. I guess the auto correction was the key. Thank you
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome, Robert ~ it is also better to use relative referencing such as Me. -- and use state abbreviation instead of the state name since New York has a space. Also good to test each control.
0
Robert WardlowPresidentAuthor Commented:
Thanks,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.