Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    VBA hyperlink


    Hello,

    Below is code I'm using to generate links to job locations in the business. Problem is, when the postcode has a space in it, the link cuts off short.

    I can easily rectify this by removing all spaces, but I was wondering if I can define the whole thing as a hyperlink?


    Code:
      
                   .Body = vbCrLf & "Map: http://www.google.com/maps?q=" & Me!Postcode & "+UK"

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    If you use .htmlbody instead of body, then you can build the whole link:
    .HTMLBody = "<br>Map: " & "<a href=""http://www.google.com/maps?q=" & Me!Postcode & "+UK" & ">" & "http://www.google.com/maps?q=" & Me!Postcode & "+UK" & "</a>"

    In theory that should work.

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I haven't done this for a while, but the routine I used has the following
    Code:
    ...sQuery = "http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address="
    50    sQuery = sQuery & Replace(sAddr, " ", "+")
    ...
    It replaces spaces in the evolving URL with a "+"

    Good luck

  4. #4
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Thanks both!

    Took some time, but I've got it. Its almost like I know what I'm doing.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-05-2013, 11:07 AM
  2. help with hyperlink
    By bmd in forum Access
    Replies: 1
    Last Post: 08-24-2011, 12:41 PM
  3. Replies: 4
    Last Post: 01-31-2011, 03:19 PM
  4. Where is the hyperlink....
    By amer in forum Queries
    Replies: 1
    Last Post: 06-09-2010, 12:06 PM
  5. Hyperlink Help
    By smikkelsen in forum Access
    Replies: 9
    Last Post: 03-12-2010, 11:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums