This Worked.
Access.FollowHyperlink
"
http://www.mapquest.com/maps/map.adp?formtype=address&searchtype=address&ad
dress=1600%20pennsylvania%20Ave&city=Washington&state=DC&zip="
So Therefore ......
Access.FollowHyperlink "
http://www.mapquest.com/maps/map.adp?" & _
"formtype=address&searchtype=address" & _
URLEncode("&address=" & Trim(nz([stAddress],"") & _
"&city=" & trim(nz([stCity],"")) & _
"&state=" & trim(nz([stState],"")) & _
"&zip=" & trim(nz([stZip],"")))
will also work as it should pproduce the same URL as the one above. To help
you debug the process you can add the following clode just below the
FolowHyperlink method
Debug.Print ""
http://www.mapquest.com/maps/map.adp?" & _
"formtype=address&searchtype=address" & _
URLEncode("&address=" & trim(nz([stAddress],"") & _
"&city=" & trim(nz([stCity],"")) & _
"&state=" & trim(nz([stState],"")) & _
"&zip=" & trim(nz([stZip],"")))
Which will print the string that is being passed to the FollowHyperlink
method in the Immediate window.
Ron W
www.WorksRite.com
Ron,
Ok, I tried to use access.FollowHyperlink and here's what I came up with:
Private Sub Strip_Map_Enter()
On Error GoTo Err_Strip_Map_Enter
Dim stAddress As String
Dim stCity As String
Dim stState As String
Dim stZip As String
Dim stFullAddress As String
stAddress = [ADDRESS]
stCity = [CITY]
stState = [STATE]
stZip = [ZIP]
stFullAddress = URLEncode(Trim([stAddress] & " " & [stCity] & " " &
[stState] & " " & [stZip]))
Access.FollowHyperlink "
www.mapquest.com/directions/main.adp", , -1,
False, stFullAddress, msoMethodPost
Exit_Strip_Map_Enter:
Exit Sub
Err_Strip_Map_Enter:
MsgBox Err.Description
Resume Exit_Strip_Map_Enter
End Sub
I thought that I could use the "ExtraInfo" variant to plug the
"stFullAddress" string into, thinking that I had to set the "Method" to
"MsoMethodPost" in order to get it to resolve the "stFullAddress" variable
into what the variable represented, again, instead of it taking
"stFullAddress" as a literal string. What I get is an error message
telling
me:
The expression On Click you entered as the event property setting produced
the following error: Sub or Function not defined
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
Ideas? Feels like I'm getting closser.
:
I am not sure that I understand your question. If you want to open the
users default browser and have it navigate to the URL that you have
stuffed
in a variable all you need to do is to use the Access.FollowHyperlink
command.
stFullAddress = "
http://www.google.com"
access.FollowHyperlink stFullAddress
will open a new browser window showing the Google home page.
Does this answer your question???
Ron W
www.WorksRite.com
Ron,
Definately a setp in the right direction. I think I can get
URLEncode
to
look at all four fields as one by writing it like:
URLEncode([stAddress]& " " &[stcity]& " " &[stState]& " " &[stZip])
and assuming I can assign it to a string like this:
stFullAddress = URLEncode([stAddress]& " " &[stcity]& " " &[stState]&
" "
&[stZip])
how can I plug stFullAddress into a line of code directing it to open
a
URL
which doesn't take stFullAddress literally, but understands that it's
a
variable that means something else?
:
This is a VB solution, but at a glance looks like it will be a
direct
port
to Access VBA.
http://www.vb-helper.com/howto_url_encode_string.html
Ron W
www.WorksRite.com
I am trying to place a control on one of my forms that links
automatically
to
maps.google.com (or any driving directions web site for that
matter)
by
taking the street address, city, state, and/or zip in the database
and
building that into the web address. For example,
http://maps.google.com/maps?q=jfk+to+350+5th+ave,+new+york&spn=0.121913,0.233854&hl=en
gives directions from JFK airport (q=jfk) to 350 5th Ave, New
York, NY
10118. In my database, the street address is all in one field
[address]
and
would contain "350 5th Ave". SOOO....
1) How do I replace the space between the street number and the
multiple
words in the street name with a "+" or a "%20" as appropriate?
2) Can the whole thing be done with an inserted hyperlink on the
form, or
do I need to do something else?