Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16

    Generare un percorso GoogleMaps

    Salve a tutti sono nuovo del Forum.
    Non sono tanto pratico di Access ma con alcune basi semplici riesco a fare dei piccoli programmi.
    Ovviamente devo incrementare le mie basi.
    Vorrei farvi una domanda...
    Ho un pulsante in una maschera che al suo Clic mi apre una posizione su googleMaps perché va a leggere il codive VBA e un campo di una tabella che si chiama [CoordinatediPartenza]
    Io vorrei fare in modo che cliccando mi possa creare il percorso da casa mia al punto delle coordinate. Tenete conto che l'indirizzo di partenza è sempre quello e non ho un campo nel database con questo indirizzo e quindi vorrei integrarlo nel codice VBA
    Il mio codice attuale del pulsante è questo:

    Private Sub Comando340_Click()
    [Comando340].HyperlinkAddress = "https://www.google.it/maps/place/" & [CoordinatediPartenza]


    End Sub

    Grazie se mi date una mano mi fate contento.
    Buona giornata

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    Luciano71,

    Not all readers are fluent in Italian. Suggest you post (at least a copy) in English via Google Translate.
    Welcome to the forum.

    English version of post #1

    Generate a GoogleMaps route

    Hello everyone, I'm new to the forum.
    I'm not very familiar with Access but with some simple basics I can make small programs.
    Obviously I have to increase my foundation.
    I would like to ask you a question ...
    I have a button in a form that opens a position on googleMaps when it clicks because it reads the VBA code and a field of a table called [CoordinatediPartenza]
    I would like to make sure that by clicking I can create the path from my house to the coordinate point. Keep in mind that the starting address is always the same and I don't have a field in the database with this address and therefore I would like to integrate it into the VBA code
    My current button code is this:

    Code:
    Private Sub Comando340_Click ()
         [Comando340] .HyperlinkAddress = "https://www.google.it/maps/place/" & [CoordinatediPartenza]
         End Sub
    Thanks if you give me a hand you make me happy.
    Good day


    Invece dell'indirizzo del collegamento ipertestuale, ti suggerisco di rivedere
    Application.FollowHyperlink
    https://docs.microsoft.com/en-us/off...ollowhyperlink

  3. #3
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16
    Hello everyone, I'm new to the forum.
    Rightly, being Italian, I didn't think of translating the writing from Italian to English.
    I hope that with Google translate you can understand what is being translated.
    I said .....

    I'm not very familiar with Access but with some simple basics I can make small programs.
    Obviously I have to increase my foundation.
    I would like to ask you a question ...
    I have a button in a form that when you click it opens a position on google Map because it reads the VBA code and a field of a table that is called
    I would like to make sure that by clicking I can create the path from my house to the coordinate point. Keep in mind that the starting address is always the same and I don't have a field in the database with this address and therefore I would like to integrate it into the VBA code
    My current button code is this:

    Private Subcommand340_Click ()
    [Comando340] .HyperlinkAddress = "https://www.google.it/maps/place/" & [CoordinatediPartenza]
    End Sub

    Thanks if you give me a hand you make me happy.
    Good day

  4. #4
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16
    Hello everyone, I'm new to the forum.
    Rightly, being Italian, I didn't think of translating the writing from Italian to English.
    I hope that with Google translate you can understand what is being translated.
    I said .....

    I'm not very familiar with Access but with some simple basics I can make small programs.
    Obviously I have to increase my foundation.
    I would like to ask you a question ...
    I have a button in a form that when you click it opens a position on google Map because it reads the VBA code and a field of a table that is called
    I would like to make sure that by clicking I can create the path from my house to the coordinate point. Keep in mind that the starting address is always the same and I don't have a field in the database with this address and therefore I would like to integrate it into the VBA code
    My current button code is this:

    Private Subcommand340_Click ()
    [Comando340] .HyperlinkAddress = "https://www.google.it/maps/place/" & [CoordinatediPartenza]
    End Sub

    Thanks if you give me a hand you make me happy.
    Good da

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,020
    I would generate the url from your location to a destination in Google Maps.

    Then identify where the destination part is in that string and replace that with your field/control.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,123
    Please try something similar to this:

    Code:
    Dim strFrom As String, strTo As String
    Dim sMyAddress as string, sHomeAddress as string
    On Error Resume Next
    
    sHomeAddress="Enter your house address here"   'replace the explanatory string on the left with your proper home address
    sMyAddress = Me.[CoordinatediPartenza]
    strFrom = "from: " & sHomeAddress
    strTo = " to: " & sMyAddress
    
    Application.FollowHyperlink "http://www.google.com/maps?q=" & strFrom & " " & strTo
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16
    First of all, thank you very much for the answer I am attaching you as the code now appears but it does not work for me. Or rather it works partially but does not generate the route.
    I'm certainly doing something wrong




    Private Sub Comando340_Click()
    Dim strFrom As String, strTo As String
    Dim sMyAddress As String, sHomeAddress As String
    On Error Resume Next


    sHomeAddress = "Via Antonio Locatelli 18 Castelli Calepio Bg Italia" 'replace the explanatory string on the left with your proper home address
    sMyAddress = Me.[CoordinatediPartenza]
    strFrom = "from: " & sHomeAddress
    strTo = " to: " & sMyAddress


    Application.FollowHyperlink "http://www.google.com/maps?q=" & strFrom & " " & strTo
    End Sub

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,020
    Put it all into a string and debug.print the string, then copy and paste it into a browser url.

    In fact using some known postcodes here
    Code:
    http://www.google.com/maps?q=from:SA4 4HG to:SA5 8ER
    works fine?

  9. #9
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16
    One moment please it becomes a bit difficult for me I struggle to understand I don't know the VBA code and its functions but I know what it is for.
    So you're telling me I have to put it all on one line.
    First thing...
    Where should I put everything on one line? Should I then concatenate with (&)?
    Then do I have to Debug and then paste in the browser?
    Well, let's take it step by step, sorry but it's a bit challenging for me as I'm not really in the trade.
    Thanks for your patience

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,020
    Quote Originally Posted by Luciano71 View Post
    One moment please it becomes a bit difficult for me I struggle to understand I don't know the VBA code and its functions but I know what it is for.
    So you're telling me I have to put it all on one line.
    First thing...
    Where should I put everything on one line? Should I then concatenate with (&)?
    Then do I have to Debug and then paste in the browser?
    Well, let's take it step by step, sorry but it's a bit challenging for me as I'm not really in the trade.
    Thanks for your patience
    What I am suggesting is some simple debugging.
    If you build the string, then you can Debug.Print it and in the immediate window you will see what it actually is, not what you *think* it is.?
    Then you can copy that string and paste into the browser url. That then should give you your route or fail.

    So you are testing each step in the process, one step at a time.

    -so your code would look like

    Code:
    Application.FollowHyperlink strUrl
    and strUrl might be
    Code:
    http://www.google.com/maps?q=from:SA4 4HG to:SA5 8ER

  11. #11
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16
    Ok I more or less understood what you mean but when you talk about building the string I don't know how to do it. Then I realized that I have to debug and the result it gives me I have to paste it in the URL of my browser.
    If you have time, explain to me how the string is built. I don't want to get too troubled otherwise I try to apply myself better by following some video instructions of how to do it otherwise if you can help me wait.
    Thank you so much.

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,020
    Code:
    Dim strUrl as String
    .... your code here
    ....
    strUrl = "http://www.google.com/maps?q=" & strFrom & " " & strTo
    Debug.Print strUrl
    ' Application.FollowHyperlink strUrl ' Comment out until it works

  13. #13
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16
    As I repeat I have more or less understood what needs to be done but not entirely. In short, looking on the net we talk about API code and most likely I have to insert it once I have obtained this string in this position
    & "" & of this string ....
    Application.FollowHyperlink "http://www.google.com/maps?q=" & strFrom & "" & strTo


    ...but I do not know how I can do it.
    I hope at least I understand that you need the API code and insert it at that point of the string-
    Can you confirm this for me?
    For the rest I have to understand how to generate the Debug and then insert it in the code.


    Have patience I hope to make it these days.
    Have patience I hope to make it these days.

  14. #14
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,123
    I have put your address like this
    Code:
    strFrom = "Via Antonio Locatelli, 18 24060 Castelli Calepio BG Italy"
    for the strTo I used:
    Code:
    strTo="Hotel Mercure Bergamo Palazzo Dolci, Bergamo, Italy"
    and this is what I got:
    Click image for larger version. 

Name:	Capture.jpg 
Views:	32 
Size:	164.9 KB 
ID:	43358

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  15. #15
    Luciano71 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    16
    Good evening, I'm back. First of all I would like to thank you again and I would like to clarify why maybe I am explaining wrong or the Google translator does not translate exactly what I mean and therefore you risk not understanding us. I'm asking if you can answer the questions so that we can understand each other this way.
    1) Do I need to generate an API key?
    2) If so, I'm not sure how.
    3) If the API key is right, should I enter it here? & "" &
    4) Of this string? Application.FollowHyperlink "http: // www. Google.com/maps?q=" & strFrom & "" & strTo If that's how I understand, can you explain how to do it?

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

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