MapQuest Buitton on Form

B

BillD

Arvin: Hope you see this post.
Mapquest must have changed their code. My Mapquest button on the form does
not work anymore. The reason is that in Canadian Postal Codes there is a
space (ie. E3A 3N7). My data is stored this way. Mapquest used to accept this
format but not anymore. How do I delete the space in the hyperlink created
from the event on click (button on Form).
Your help would be greatly appreciated again. Here is my code.
Private Sub cmdHyperlink_Click()
Dim strPath As String
If Not IsNull(Me.Postal_Code) Then
strPath = "http://www.mapquest.com/maps/" & Me.Postal_Code & "/"
Me.cmdHyperlink.HyperlinkAddress = strPath
End If
End Sub
 
D

Dirk Goldgar

BillD said:
Arvin: Hope you see this post.
Mapquest must have changed their code. My Mapquest button on the form does
not work anymore. The reason is that in Canadian Postal Codes there is a
space (ie. E3A 3N7). My data is stored this way. Mapquest used to accept
this
format but not anymore. How do I delete the space in the hyperlink created
from the event on click (button on Form).
Your help would be greatly appreciated again. Here is my code.
Private Sub cmdHyperlink_Click()
Dim strPath As String
If Not IsNull(Me.Postal_Code) Then
strPath = "http://www.mapquest.com/maps/" & Me.Postal_Code & "/"
Me.cmdHyperlink.HyperlinkAddress = strPath
End If
End Sub


It looks to me like you can use either:

strPath = "http://www.mapquest.com/maps/" & _
Replace(Me.Postal_Code, " ", "") & "/"

.... or:

strPath = "http://www.mapquest.com/maps/" & _
Replace(Me.Postal_Code, " ", "+") & "/"


MapQuest seems to be pretty flexible in what it accepts.
 
A

Arvin Meyer [MVP]

You can remove spaces with this code:

Public Function RemoveSpaces(strIn As String) As String
' Arvin Meyer 3/24/2004
Dim i As Integer
Dim strOut As String
Dim c As String
strOut = ""
If ((Not IsNull(strIn)) And (strIn <> "")) Then
For i = 1 To Len(strIn)
c = Mid(strIn, i, 1)
If (InStr(1, " ", c) = 0) Then
strOut = strOut + c
End If
Next i
End If
RemoveSpaces = strOut
End Function

But I don't think that will solve your problem. You can fill spaces in an
URL with "%20" (no quotes), so you might try parsing the zip code and
inserting %20 as needed.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
B

BillD

Sorry for being late answering this post. I did not receive a notice that
anyone had replyed to my post. Thank you so much Arvin, Dirk and Petr. A
special thanks to Arvin who originally gave me the code for MapQuest Button.
I will try this code and report back. This post will be helpful to a lot of
members. "You make a living by what you get and a life by what you give".
Thanks again
Bill D.
 

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