Populate Bing Maps String (1 Viewer)

Douglas Post

Registered User.
Local time
Today, 09:30
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.
 

Douglas Post

Registered User.
Local time
Today, 09:30
Joined
Feb 10, 2012
Messages
22
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.
 

Douglas Post

Registered User.
Local time
Today, 09:30
Joined
Feb 10, 2012
Messages
22
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.
 

Andrwal6

New member
Local time
Today, 13:30
Joined
Oct 11, 2009
Messages
4
Should you not Replace(FullAddress," ","%20") which replaces all spaces with "%20"
 

isladogs

MVP / VIP
Local time
Today, 13:30
Joined
Jan 14, 2017
Messages
18,186
Agree with @Andrwal6. Code will terminate at the first space so you need to replace spaces with %20.
 

Users who are viewing this thread

Top Bottom