Populate Bing Maps String

Douglas Post

Registered User.
Local time
Today, 15:05
Joined
Feb 10, 2012
Messages
22
I have a form that contains the following fields:

  • Address
  • City
  • State
  • Zip
I convert this to FullAddress with:

Code:
Dim FullAddress As String
FullAddress = Address & " " & City & " " & State & " " & Zip
I am outputting to Outlook and want to create a link to Bing Maps with:
Code:
"<br><A HREF=http://www.bing.com/maps/?v=2&where1=" & FullAddress & "&sty=b>Bing Maps</A>"
Somehow the A HREF function truncates the string to the first space contained in the FullAddress. So if the address read "5822 Cranston, Portage, MI 49002", the actual output hyperlink is:

http://www.bing.com/maps/?v=2&where1=5822

Instead of what I want it to do which is :

http://www.bing.com/maps/?v=2&where1=5822 Cranston, Portage, MI 49002 &sty=b

I realize that HREF may not like spaces but my field Address has the street number and address in the same field instead of separate fields.
 
I got it to work by seperating the address string:

Code:
Dim StreetNumber As String
Dim StreetName As String

StreetNumber = Left(Me!Address, InStr(1, Me!Address, " ") - 1)
StreetName = Right(Me!Address, InStr(1, Me!Address, " ") + 1)

"<br><A HREF=http://www.bing.com/maps/?v=2&where1=" & StreetNumber & " " & StreetName & " " & City & " " & State & " " & Zip & " " & "&sty=b>Bing Maps</A>"
Please tell me there is a better way. HREF just stops at the first blank space.
 
Actually doesn't work.

Works ok for addresses like 5822 Cranston but does not work for 10603 S Cascade Street as the output for the latter is 10603 Street.
 
Should you not Replace(FullAddress," ","%20") which replaces all spaces with "%20"
 
Agree with @Andrwal6. Code will terminate at the first space so you need to replace spaces with %20.
 

Users who are viewing this thread

Back
Top Bottom