Post Code to Google Maps (1 Viewer)

TrickyDicky

New member
Local time
Today, 06:30
Joined
Aug 23, 2007
Messages
6
After my post in the general forms (titled thank you) this Post might contradict me - You see after introducing myself I expressed that I've never had to post a topic because up to now all my questions have been answered, and I found the answer by using the search function. But now I'm afraid that I'm going to ask a question which looks to have been answered, but I am afraid I am not able to follow.

I would like to know how to add a Hyper link in my form linking the Post Code to Google Maps so that Google Maps shows the location of the post code

and

This may be to difficult for access to do BUT I would like it so when I click my post code (or a button linked to the postcode) it opens Google Maps and shows directions from my company's Workshop to the Post code in question

Thanks :D
 

dan1dyoung

Registered User.
Local time
Today, 13:30
Joined
Apr 9, 2005
Messages
76
Post Code to Google

Hi,

I use the below for multimap and internet explorer with the field Postcode, a button called CmdViewMap, but you could change it to suit Google or whatever you like, maybe change the browser for firefox, e.t.c.

For Google try changing the line:
strLink = "http://www.multimap.com/map/browse.cgi?pc=" & Me.Postcode
To
strLink = "http://maps.google.co.uk/maps?f=q&hl=en&geocode=&q=" & Me.Postcode

Code:
Private Sub CmdViewMap_Click()
On Error GoTo Err_CmdViewMap_Click

    Dim strLink As String

    
    strLink = "http://www.multimap.com/map/browse.cgi?pc=" & Me.Postcode
    strLink = "C:\Program Files\Internet Explorer\IEXPLORE.EXE " & strLink
            
    Call Shell(strLink, vbMaximizedFocus)

Exit_CmdViewMap_Click:
    Exit Sub

Err_CmdViewMap_Click:
    MsgBox Err.Description
    Resume Exit_CmdViewMap_Click
    
End Sub

Just checked Google, for directions from your Postcode to the Postcode in the database try the below (Replacing the YOUR POSTCODE with your postcode/start postcode):

strLink = "http://maps.google.co.uk/maps?f=d&hl=en&geocode=&saddr=YOUR POSTCODE&daddr=" & Me.Postcode

Just tested all the paths and they seem OK

Thanks

Dan
 
Last edited:

stopher

AWF VIP
Local time
Today, 14:30
Joined
Feb 1, 2006
Messages
2,395
or..

Code:
FollowHyperlink "http://maps.google.co.uk/maps?f=q&hl=en&geocode=&q=" & Me!PostCode

Chris
 

TrickyDicky

New member
Local time
Today, 06:30
Joined
Aug 23, 2007
Messages
6
Alrightio - Please be patient with me because this is the first time with me using codes in Microsoft Access.
I have tried out dan1dyoung option - but I haven't been able to make it work.
At the moment the code I have got is -

Code:
Private Sub CmdViewMap_Click()
On Error GoTo Err_CmdViewMap_Click

    Dim strLink As String

    
    strLink = "http://www.multimap.com/map/browse.cgi?pc=" & Me.Postcode
    strLink = "C:\Program Files (x86)\Gran Paradiso\firefox.exe" & strLink
            
    Call Shell(strLink, vbMaximizedFocus)

Exit_CmdViewMap_Click:
    Exit Sub

Err_CmdViewMap_Click:
    MsgBox Err.Description
    Resume Exit_CmdViewMap_Click
    
End Sub

I have a button named CmdViewMap, but nothing happens when I click it.
Thanks for helping out! :D
 

stopher

AWF VIP
Local time
Today, 14:30
Joined
Feb 1, 2006
Messages
2,395
You need a space after firefox.exe
So Firefox.exe" becomes firefox.exe "

How did you add your button and code? Go into the properties for the button and check to see if there is something in the OnClick event (it's quite possible to write code without it being tied to an event).

If you want to check that your code is actually running, then put the following line just after the DIM statement:

MsgBox "my code is running", vbOKOnly

If a message box pops up then obviously the code is running and there is something wrong with the rest of the code. If the message box doesn't pop up then I reckon your code isn't actually linked to your OnClick event in your button.

Take a look at the code. The only interesting bit is the 4 lines starting with DIM and ending with CALL SHELL. The rest just handles errors if things go wrong.

There's nothing wrong with TrickyDicky's solution that I can see. The only reason I suggested using the FollowHyperlink command (1 line instead of 4) is because you don't need to worry about what browser you are using or where it is located. It will just launch the link in the default browser (handy if you are using your application on different computers).

I attach an example.

Chris
 

Attachments

  • postcode.zip
    10.8 KB · Views: 587

TrickyDicky

New member
Local time
Today, 06:30
Joined
Aug 23, 2007
Messages
6
Sorted!

I downloaded stopher example and found that clicking his button didn't do anything either. Then I noticed a small message at the top of Microsoft Access stating "security threat found, click to enable". I had a look in my database and guess what - yep same message - what a dumbass!:eek: - after clicking enable, all has worked fine!
Yet to add a button to find directions from my companys workshop to Postcode in question, but since dan1dyoung original code worked so well - i'll try and use his solution.

Thanks all :D
 

dan1dyoung

Registered User.
Local time
Today, 13:30
Joined
Apr 9, 2005
Messages
76
Cool, Glad you got it sorted.

For the directions from your workshop to the postcode, just change it to

strLink = "http://maps.google.co.uk/maps?f=d&hl=en&geocode=&saddr=YOUR WORKSHOP POSTCODE&daddr=" & Me.Postcode

Thanks

Dan
 

Users who are viewing this thread

Top Bottom