Results 1 to 2 of 2
  1. #1
    cggriggs is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    4

    Getting a map to display


    I have a form that I input and display address and similar contact data. I would like to place a button on the form and when selected, it would display a map based upon the current address showing in the form [address], [City], [State]in the form. Any suggestions? Thanks for any help.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    The On Click event for the button on your Form should call a procedure like this. You would get the sAddr value from the current address shown on your form.

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : StreetToGoogleMap
    ' Author    : Jack (using Acc2003)
    ' Created   : 7/13/2011
    ' Purpose   : To output a google map based on a street address
    '   consisting of
    '            Street, City/Town, State/Prov, Country
    '---------------------------------------------------------------------------------------
    ' Last Modified:
    '
    ' Inputs: sAddr ( a string representing an address)
    ' Dependency: N/A
    '------------------------------------------------------------------------------
    '
    Sub StreetToGoogleMap(sAddr As String)
    '
    'NOTE: Google Maps will try to give you a map. It may not be what you expected.
    '      If you "guess" a city in a state, and there is NO such place, Google map
    '      will give you a result based on his algorithm. It may be in a totally
    '      different state or country.
    '
    
    Dim sLink As String
    
       On Error GoTo StreetToGoogleMap_Error
    ' General gmap link -- NO Key required **********
    sLink = "http://maps.google.com/maps?f=q&hl=en&q="
    
    ' a street address for sample map
    ' Sample addresses to try:
    'MyStreet = " 25 James  Street, Kingston,ON,CANADA"
    'MyStreet = " 25 James  Street, Kingston,NY,USA"
    'MyStreet = " 25 James  Street, Kingston,PA, USA"
    'MyStreet = " 25 James  Street, Kingston,California, USA"
    'MyStreet = " 25 James  Street, Kingston,California,90210, USA"
    
    '******** N O T E **************************************
    '*******************************************************
    ' Google maps insists on returning  PA even though
    ' California was spelled out.
    '
    'When I added a 90210 Zip, Google maps recognized that the
    'coordinates are not a valid address. He returns a message
    'on a map of the USA.
    '
    'Msg from Maps
    ' We were not able to locate the address:
    '25 James Street, Kingston, California, 90210, USA
    '
    'Would you like to:
    '
    '   * Get a map of 25 James St, Kingston, PA 18704
    '
    '*************************************************
    '********** B  E   A D V I S E D *****************
    
    'Show map using MyStreet
    
    Application.FollowHyperlink sLink & sAddr, , True
    
       On Error GoTo 0
       Exit Sub
    
    StreetToGoogleMap_Error:
    
        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure StreetToGoogleMap"
    End Sub
    Here is a small routine to test the above procedure.

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : JTestSAddr
    ' Author    : Jack
    ' Created   : 7/13/2011
    ' Purpose   : Sample procedure to create a Google Map
    '   based on street address passed as an input parameter
    '---------------------------------------------------------------------------------------
    ' Last Modified:
    '
    ' Inputs: N/A
    ' Dependency: N/A
    '------------------------------------------------------------------------------
    '
    Sub JTestSAddr()
    Dim myStreet As String
       On Error GoTo JTestSAddr_Error
       
       ' a street address for sample map
    ' Sample addresses to try:
    'MyStreet = " 25 James  Street, Kingston,ON,CANADA"
    'MyStreet = " 25 James  Street, Kingston,NY,USA"
    'MyStreet = " 25 James  Street, Kingston,PA, USA"
    'MyStreet = " 25 James  Street, Kingston,California, USA"
    'MyStreet = " 25 James  Street, Kingston,California,90210, USA"
    
    '******** N O T E **************************************
    '*******************************************************
    ' Google maps insists on returning  PA even though
    ' California was spelled out.
    '
    'When I added a 90210 Zip, Google maps recognized that the
    'coordinates are not a valid address. He returns a message
    'on a map of the USA.
    '
    'Msg from Maps
    ' We were not able to locate the address:
    '25 James Street, Kingston, California, 90210, USA
    '
    'Would you like to:
    '
    '   * Get a map of 25 James St, Kingston, PA 18704
    '
    '*************************************************
    '********** B  E   A D V I S E D *****************
    
    
    myStreet = "50 Second Ave, Tucson, AZ"
    StreetToGoogleMap (myStreet)
    
       On Error GoTo 0
       Exit Sub
    
    JTestSAddr_Error:
    
        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure JTestSAddr of Module GoogleMapsEtc"
    End Sub

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

Similar Threads

  1. Need help with data display
    By Buakaw in forum Forms
    Replies: 7
    Last Post: 03-14-2011, 05:59 AM
  2. matrix display
    By radujit in forum Queries
    Replies: 1
    Last Post: 01-25-2011, 10:37 AM
  3. How do I display the last record?
    By daddylongtoe in forum Access
    Replies: 1
    Last Post: 06-21-2010, 10:01 AM
  4. Report control of a field display/no display
    By systems013 in forum Reports
    Replies: 5
    Last Post: 02-01-2010, 09:44 AM
  5. Combo Box Display
    By ssaucedo in forum Reports
    Replies: 17
    Last Post: 08-10-2009, 05:52 PM

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