Google Maps: StartingPoint & Destination, then get results.

R

ryguy7272

I have one TextBox named:
strStartingPoint

I have another TextBox named:
strDestination


'**********Begin Code************************

Option Compare Database
Option Explicit

Sub GoogleMap_Click(strStartingPoint As String, strDestination As String)

' 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

I got the idea from here:
http://www.microsoft.com/office/com...92a7&mid=a92eb5f7-f9c4-4471-820e-f745efc3f54f

When the code fires, I keep getting this message:
I keep getting a message that says â€The Expression On Click you entered as
the event property setting produced the following error: Procedure
declaration does not match description of event or procedure having the same
name.â€


What am I doing wrong? I just can’t see it.

Thanks,
Ryan---
 
J

John W. Vinson

When the code fires, I keep getting this message:
I keep getting a message that says ”The Expression On Click you entered as
the event property setting produced the following error: Procedure
declaration does not match description of event or procedure having the same
name.”

Your Sub statement reads:

Sub GoogleMap_Click(strStartingPoint As String, strDestination As String)

The Click event of a command button has no arguments. Access is expecting that
a command button named GoogleMap will call a subroutine defined as

Sub GoogleMap_Click()


and that the code would retrieve the arguments from form controls.
 
R

ryguy7272

Awesome! I tried a few things but nothing worked. Thanks for pointing that
out.
Ryan---
 

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

Similar Threads


Top