Form1 code:
Private Sub GMaps_Click_Click()
Dim MyHyperlink As String
Dim strGoogleLoaction As String
strGoogleLoaction = Replace([txtCodesPostale], " ", "+")
MyHyperlink = "
http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q="
& strGoogleLoaction &
"&sll=40.784181,-73.949189&sspn=0.014882,0.030942&ie=UTF8&t=h&z=12"
Application.FollowHyperlink MyHyperlink
End Sub
Form contains one TextBox, named ‘txtCodesPostale’ and a CommandButton.
Form2 code:
'**********Begin Code************************
Option Compare Database
Option Explicit
Sub GoogleMap_Click()
'
http://www.utteraccess.com/forums/showflat.php?Cat=&Number=1356166
' Given a FROM address and TO address, will start Internet Explorer,
' and call up GoggleMaps to give directions with total mileage estimate!
' Example of calling from Immediate window to get directions from
' the Space Needle in Seattle to the White House in Wash. DC, USA:
' Call GoogleMap("1600 Pennsylvania Avenue, Washington, DC", _
"400 Broad St, Seattle, WA 98109")
Dim strURL As String
Dim ie As Object
'Convert spaces to + sign
strStartingPoint = Replace(strStartingPoint, " ", "+")
strDestination = Replace(strDestination, " ", "+")
strURL = "
http://maps.google.com/maps?f=d&hl=en&saddr=" & strStartingPoint &
"&daddr=" & strDestination & "&ie=UTF8&z=5&om=1"
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate strURL
ie.Visible = True
End Sub
Public Function Mapper_Click(strCity As Variant, strState As Variant,
strAddress As Variant, strZip As Variant) As Variant
' Example of calling from Immediate Window for the Space Needle
' located in Seattle, WA., USA:
' Call Mapper_Click ("Seattle", "WA", "400 Broad St", "98109")
On Error GoTo Err_Mapper_Click
Dim strFullAddress As Variant
Dim strMapquest As Variant
strFullAddress = strAddress & "&city=" & strCity _
& "&state=" & strState _
& "&zipcode=" & strZip
strMapquest = "
http://www.mapquest.com/maps/map.adp?searchtype=" &
"address&formtype=search&countryid=US" & "&addtohistory=&country=US&address="
& strFullAddress & "&historyid=&submit=Get Map"
'Remove trailing spaces
strMapquest = Trim(strMapquest)
'Change imbedded spaces with plus signs
strMapquest = Replace(strMapquest, " ", "+", 1, , vbTextCompare)
Application.FollowHyperlink strMapquest, , True
strMapquest = vbNullString
Exit_Mapper_Click:
Exit Function
Err_Mapper_Click:
MsgBox Err.Number & "-" & Err.Description
Resume Exit_Mapper_Click
End Function
Form contains two TextBoxes:
‘strStartingPoint’ and ‘strDestination’ and a CommandButton.
There are some examples online; Google for them.