Help with Google Maps

Help with Google Maps

am 22.04.2008 16:26:31 von pagina21

I am a true beginner in Access and coding.

I am creating a database with facility information and I want to use
the address of a specific facility to display a map on my form or at
least open a new window with the address already plugged into Google
maps.

I don't even know where to begin. Can someone please help?

Re: Help with Google Maps

am 22.04.2008 17:19:28 von Salad

pagina21@gmail.com wrote:
> I am a true beginner in Access and coding.
>
> I am creating a database with facility information and I want to use
> the address of a specific facility to display a map on my form or at
> least open a new window with the address already plugged into Google
> maps.
>
> I don't even know where to begin. Can someone please help?

These 2 routines might help. I have a form with 4 fields; City, State,
Address, and ZipCode. MakeUrl calls routine CreateUrl that makes the
URL for googlemaps.

On my form I also suppled 4 more fields; ToCity, ToState, ToAddress, and
ToZipCode if I want driving instructions.

I pass strType to MakeUrl. If blank, it creates the URL for displaying
a map of the location specified. If strType = "Driving" then I create
the URL for driving instructions. It opens InternetExplorer to the URL.

If the fields on your form match my field names it's ready to run as-is.
If not, change the field names in the code below to match your textbox
field names.

Then create a command button. In the OnClick event enter
MakeUrl "" 'no driving instructions
or
MakeUrl "Driving" 'driving instructions.

Private Sub MakeURL(strType As String)
On Error GoTo Err_MakeURL
Dim strURL As String
Dim objBrowser As Object

If IsNull(Me.City) Or IsNull(Me.State) Then
MsgBox "You need to supply at least the city and state."
Me.City.SetFocus
Else
strURL = CreateUrl(Me.Address, Me.City, Me.State, Me.ZipCode)

If strType = "Driving" Then
strURL = strURL & "+" & "to" & "+" &
CreateUrl(Me.ToAddress, Me.ToCity, Me.ToState, Me.ToZipCode)
End If
strURL = "http://maps.google.com/maps?q=" & strURL &
"&iwloc=A&hl=en"

Dim obj As Object
Set obj = CreateObject("InternetExplorer.Application")
With obj
.Navigate2 strURL
.Visible = True
End With
Set obj = Nothing
End If
Exit_MakeURL:
Exit Sub

Err_MakeURL:
MsgBox Err.Description
Resume Exit_MakeURL

End Sub
Private Function CreateUrl(strAddress As Variant, strCity As String,
strState As String, strZip As Variant) As String
'generate the URL to pass to Google in browser.
Dim strURL As String
Dim strOrig As String
Dim intPos As Integer

If Not IsNull(strAddress) Then
strOrig = strAddress
Do While True
If strOrig <> "" Then
intPos = InStr(strOrig, " ")
If intPos > 0 Then
strURL = strURL & Left(strOrig, intPos - 1) & "+"
strOrig = LTrim(Mid(strOrig, intPos + 1))
Else
strURL = strURL & strOrig & "+"
Exit Do
End If
Else
Exit Do
End If
Loop
End If
strURL = strURL & strCity & "+" & strState & "+"
If Not IsNull(strZip) Then strURL = strURL & strZip & "+"

CreateUrl = Left(strURL, Len(strURL) - 1)

End Function

RaceCard
http://www.youtube.com/watch?v=1FQtN2NbGv8

Re: Help with Google Maps

am 22.04.2008 19:19:12 von pagina21

On Apr 22, 10:19=A0am, Salad wrote:
> pagin...@gmail.com wrote:
> > I am a true beginner in Access and coding.
>
> > I am creating a database with facility information and I want to use
> > the address of a specific facility to display a map on my form or at
> > least open a new window with the address already plugged into Google
> > maps.
>
> > I don't even know where to begin. Can someone please help?
>
> These 2 routines might help. =A0I have a form with 4 fields; City, State,
> Address, and ZipCode. =A0MakeUrl calls routine CreateUrl that makes the
> URL for googlemaps.
>
> On my form I also suppled 4 more fields; ToCity, ToState, ToAddress, and
> ToZipCode if I want driving instructions.
>
> I pass strType to MakeUrl. =A0If blank, it creates the URL for displaying
> a map of the location specified. =A0If strType =3D "Driving" then I create=

> the URL for driving instructions. =A0It opens InternetExplorer to the URL.=

>
> If the fields on your form match my field names it's ready to run as-is.
> =A0 If not, change the field names in the code below to match your textbox=

> field names.
>
> Then create a command button. =A0In the OnClick event enter
> =A0 =A0 =A0 =A0 MakeUrl "" =A0 'no driving instructions
> or
> =A0 =A0 =A0 =A0 MakeUrl "Driving" =A0'driving instructions.
>
> Private Sub MakeURL(strType As String)
> On Error GoTo Err_MakeURL
> =A0 =A0 =A0Dim strURL As String
> =A0 =A0 =A0Dim objBrowser As Object
>
> =A0 =A0 =A0If IsNull(Me.City) Or IsNull(Me.State) Then
> =A0 =A0 =A0 =A0 =A0MsgBox "You need to supply at least the city and state.=
"
> =A0 =A0 =A0 =A0 =A0Me.City.SetFocus
> =A0 =A0 =A0Else
> =A0 =A0 =A0 =A0 =A0strURL =3D CreateUrl(Me.Address, Me.City, Me.State, Me.=
ZipCode)
>
> =A0 =A0 =A0 =A0 =A0If strType =3D "Driving" Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0strURL =3D strURL & "+" & "to" & "+" &
> CreateUrl(Me.ToAddress, Me.ToCity, Me.ToState, Me.ToZipCode)
> =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 =A0 =A0strURL =3D "http://maps.google.com/maps?q=3D" & strURL =
&
> "&iwloc=3DA&hl=3Den"
>
> =A0 =A0 =A0 =A0 =A0Dim obj As Object
> =A0 =A0 =A0 =A0 =A0Set obj =3D CreateObject("InternetExplorer.Application"=
)
> =A0 =A0 =A0 =A0 =A0With obj
> =A0 =A0 =A0 =A0 =A0 =A0 =A0.Navigate2 strURL
> =A0 =A0 =A0 =A0 =A0 =A0 =A0.Visible =3D True
> =A0 =A0 =A0 =A0 =A0End With
> =A0 =A0 =A0 =A0 =A0Set obj =3D Nothing
> =A0 =A0 =A0End If
> Exit_MakeURL:
> =A0 =A0 =A0Exit Sub
>
> Err_MakeURL:
> =A0 =A0 =A0MsgBox Err.Description
> =A0 =A0 =A0Resume Exit_MakeURL
>
> End Sub
> Private Function CreateUrl(strAddress As Variant, strCity As String,
> strState As String, strZip As Variant) As String
> =A0 =A0 =A0'generate the URL to pass to Google in browser.
> =A0 =A0 =A0Dim strURL As String
> =A0 =A0 =A0Dim strOrig As String
> =A0 =A0 =A0Dim intPos As Integer
>
> =A0 =A0 =A0If Not IsNull(strAddress) Then
> =A0 =A0 =A0 =A0 =A0strOrig =3D strAddress
> =A0 =A0 =A0 =A0 =A0Do While True
> =A0 =A0 =A0 =A0 =A0 =A0 =A0If strOrig <> "" Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intPos =3D InStr(strOrig, " ")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0If intPos > 0 Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strURL =3D strURL & Left(strOri=
g, intPos - 1) & "+"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strOrig =3D LTrim(Mid(strOrig, =
intPos + 1))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strURL =3D strURL & strOrig & "=
+"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit Do
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 =A0 =A0 =A0 =A0Else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit Do
> =A0 =A0 =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 =A0 =A0Loop
> =A0 =A0 =A0End If
> =A0 =A0 =A0strURL =3D strURL & strCity & "+" & strState & "+"
> =A0 =A0 =A0If Not IsNull(strZip) Then strURL =3D strURL & strZip & "+"
>
> =A0 =A0 =A0CreateUrl =3D Left(strURL, Len(strURL) - 1)
>
> End Function
>
> RaceCardhttp://www.youtube.com/watch?v=3D1FQtN2NbGv8

(I'm not sure if the message I just sent you actually sent, so I'll
post again)
Could you explain this step in more detail please?

"I pass strType to MakeUrl. If blank, it creates the URL for
displaying
a map of the location specified. If strType =3D "Driving" then I
create
the URL for driving instructions. It opens InternetExplorer to the
URL. "

Sorry, I truly am a begginer.

Re: Help with Google Maps

am 23.04.2008 00:23:50 von Salad

pagina wrote:

> On Apr 22, 10:19 am, Salad wrote:
>
>>pagin...@gmail.com wrote:
>>
>>>I am a true beginner in Access and coding.
>>
>>>I am creating a database with facility information and I want to use
>>>the address of a specific facility to display a map on my form or at
>>>least open a new window with the address already plugged into Google
>>>maps.
>>
>>>I don't even know where to begin. Can someone please help?
>>
>>These 2 routines might help. I have a form with 4 fields; City, State,
>>Address, and ZipCode. MakeUrl calls routine CreateUrl that makes the
>>URL for googlemaps.
>>
>>On my form I also suppled 4 more fields; ToCity, ToState, ToAddress, and
>>ToZipCode if I want driving instructions.
>>
>>I pass strType to MakeUrl. If blank, it creates the URL for displaying
>>a map of the location specified. If strType = "Driving" then I create
>>the URL for driving instructions. It opens InternetExplorer to the URL.
>>
>>If the fields on your form match my field names it's ready to run as-is.
>> If not, change the field names in the code below to match your textbox
>>field names.
>>
>>Then create a command button. In the OnClick event enter
>> MakeUrl "" 'no driving instructions
>>or
>> MakeUrl "Driving" 'driving instructions.
>>
>>Private Sub MakeURL(strType As String)
>>On Error GoTo Err_MakeURL
>> Dim strURL As String
>> Dim objBrowser As Object
>>
>> If IsNull(Me.City) Or IsNull(Me.State) Then
>> MsgBox "You need to supply at least the city and state."
>> Me.City.SetFocus
>> Else
>> strURL = CreateUrl(Me.Address, Me.City, Me.State, Me.ZipCode)
>>
>> If strType = "Driving" Then
>> strURL = strURL & "+" & "to" & "+" &
>>CreateUrl(Me.ToAddress, Me.ToCity, Me.ToState, Me.ToZipCode)
>> End If
>> strURL = "http://maps.google.com/maps?q=" & strURL &
>>"&iwloc=A&hl=en"
>>
>> Dim obj As Object
>> Set obj = CreateObject("InternetExplorer.Application")
>> With obj
>> .Navigate2 strURL
>> .Visible = True
>> End With
>> Set obj = Nothing
>> End If
>>Exit_MakeURL:
>> Exit Sub
>>
>>Err_MakeURL:
>> MsgBox Err.Description
>> Resume Exit_MakeURL
>>
>>End Sub
>>Private Function CreateUrl(strAddress As Variant, strCity As String,
>>strState As String, strZip As Variant) As String
>> 'generate the URL to pass to Google in browser.
>> Dim strURL As String
>> Dim strOrig As String
>> Dim intPos As Integer
>>
>> If Not IsNull(strAddress) Then
>> strOrig = strAddress
>> Do While True
>> If strOrig <> "" Then
>> intPos = InStr(strOrig, " ")
>> If intPos > 0 Then
>> strURL = strURL & Left(strOrig, intPos - 1) & "+"
>> strOrig = LTrim(Mid(strOrig, intPos + 1))
>> Else
>> strURL = strURL & strOrig & "+"
>> Exit Do
>> End If
>> Else
>> Exit Do
>> End If
>> Loop
>> End If
>> strURL = strURL & strCity & "+" & strState & "+"
>> If Not IsNull(strZip) Then strURL = strURL & strZip & "+"
>>
>> CreateUrl = Left(strURL, Len(strURL) - 1)
>>
>>End Function
>>
>>RaceCardhttp://www.youtube.com/watch?v=1FQtN2NbGv8
>
>
> (I'm not sure if the message I just sent you actually sent, so I'll
> post again)
> Could you explain this step in more detail please?
>
> "I pass strType to MakeUrl. If blank, it creates the URL for
> displaying
> a map of the location specified. If strType = "Driving" then I
> create
> the URL for driving instructions. It opens InternetExplorer to the
> URL. "
>
> Sorry, I truly am a begginer.

Let's say you have a form with 4 textbox fields name; address, city,
state, zip. There's also 1 command button to call GoogleMaps...name it
CommandMap. Take my code and post it in the form's code module. If
your field names are NOT address, city, state, zip then change those
names in my code to the names of your textbox controls.

In the OnClick event of the code module you would enter
MakeUrl " "

You can check this out easily enough. Create a table with the fields
address, city, state, zip. Save the table. Open it and add a record.

Now using the form wizard (Forms/New/Wizard) create a form for that
table. Open it in design mode and add the command button CommandMap to
your form and in the OnClick of event CommandMap enter
MakeUrl " "

Save the form. Then open it and see if it works.

Now if I had 4 more textboxes on the form; toaddress, tocity, tostate,
tozip then I have a starting address and an ending address. I could get
driving instructions by entering in the OnClick of event of CommandMap
MakeUrl "Driving"

Re: Help with Google Maps

am 23.04.2008 17:41:11 von pagina21

On Apr 22, 5:23=A0pm, Salad wrote:
> pagina wrote:
> > On Apr 22, 10:19 am, Salad wrote:
>
> >>pagin...@gmail.com wrote:
>
> >>>I am a true beginner in Access and coding.
>
> >>>I am creating a database with facility information and I want to use
> >>>the address of a specific facility to display a map on my form or at
> >>>least open a new window with the address already plugged into Google
> >>>maps.
>
> >>>I don't even know where to begin. Can someone please help?
>
> >>These 2 routines might help. =A0I have a form with 4 fields; City, State=
,
> >>Address, and ZipCode. =A0MakeUrl calls routine CreateUrl that makes the
> >>URL for googlemaps.
>
> >>On my form I also suppled 4 more fields; ToCity, ToState, ToAddress, and=

> >>ToZipCode if I want driving instructions.
>
> >>I pass strType to MakeUrl. =A0If blank, it creates the URL for displayin=
g
> >>a map of the location specified. =A0If strType =3D "Driving" then I crea=
te
> >>the URL for driving instructions. =A0It opens InternetExplorer to the UR=
L.
>
> >>If the fields on your form match my field names it's ready to run as-is.=

> >> =A0If not, change the field names in the code below to match your textb=
ox
> >>field names.
>
> >>Then create a command button. =A0In the OnClick event enter
> >> =A0 =A0 =A0 =A0MakeUrl "" =A0 'no driving instructions
> >>or
> >> =A0 =A0 =A0 =A0MakeUrl "Driving" =A0'driving instructions.
>
> >>Private Sub MakeURL(strType As String)
> >>On Error GoTo Err_MakeURL
> >> =A0 =A0 Dim strURL As String
> >> =A0 =A0 Dim objBrowser As Object
>
> >> =A0 =A0 If IsNull(Me.City) Or IsNull(Me.State) Then
> >> =A0 =A0 =A0 =A0 MsgBox "You need to supply at least the city and state.=
"
> >> =A0 =A0 =A0 =A0 Me.City.SetFocus
> >> =A0 =A0 Else
> >> =A0 =A0 =A0 =A0 strURL =3D CreateUrl(Me.Address, Me.City, Me.State, Me.=
ZipCode)
>
> >> =A0 =A0 =A0 =A0 If strType =3D "Driving" Then
> >> =A0 =A0 =A0 =A0 =A0 =A0 strURL =3D strURL & "+" & "to" & "+" &
> >>CreateUrl(Me.ToAddress, Me.ToCity, Me.ToState, Me.ToZipCode)
> >> =A0 =A0 =A0 =A0 End If
> >> =A0 =A0 =A0 =A0 strURL =3D "http://maps.google.com/maps?q=3D" & strURL =
&
> >>"&iwloc=3DA&hl=3Den"
>
> >> =A0 =A0 =A0 =A0 Dim obj As Object
> >> =A0 =A0 =A0 =A0 Set obj =3D CreateObject("InternetExplorer.Application"=
)
> >> =A0 =A0 =A0 =A0 With obj
> >> =A0 =A0 =A0 =A0 =A0 =A0 .Navigate2 strURL
> >> =A0 =A0 =A0 =A0 =A0 =A0 .Visible =3D True
> >> =A0 =A0 =A0 =A0 End With
> >> =A0 =A0 =A0 =A0 Set obj =3D Nothing
> >> =A0 =A0 End If
> >>Exit_MakeURL:
> >> =A0 =A0 Exit Sub
>
> >>Err_MakeURL:
> >> =A0 =A0 MsgBox Err.Description
> >> =A0 =A0 Resume Exit_MakeURL
>
> >>End Sub
> >>Private Function CreateUrl(strAddress As Variant, strCity As String,
> >>strState As String, strZip As Variant) As String
> >> =A0 =A0 'generate the URL to pass to Google in browser.
> >> =A0 =A0 Dim strURL As String
> >> =A0 =A0 Dim strOrig As String
> >> =A0 =A0 Dim intPos As Integer
>
> >> =A0 =A0 If Not IsNull(strAddress) Then
> >> =A0 =A0 =A0 =A0 strOrig =3D strAddress
> >> =A0 =A0 =A0 =A0 Do While True
> >> =A0 =A0 =A0 =A0 =A0 =A0 If strOrig <> "" Then
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 intPos =3D InStr(strOrig, " ")
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 If intPos > 0 Then
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 strURL =3D strURL & Left(strOri=
g, intPos - 1) & "+"
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 strOrig =3D LTrim(Mid(strOrig, =
intPos + 1))
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Else
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 strURL =3D strURL & strOrig & "=
+"
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Exit Do
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 End If
> >> =A0 =A0 =A0 =A0 =A0 =A0 Else
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Exit Do
> >> =A0 =A0 =A0 =A0 =A0 =A0 End If
> >> =A0 =A0 =A0 =A0 Loop
> >> =A0 =A0 End If
> >> =A0 =A0 strURL =3D strURL & strCity & "+" & strState & "+"
> >> =A0 =A0 If Not IsNull(strZip) Then strURL =3D strURL & strZip & "+"
>
> >> =A0 =A0 CreateUrl =3D Left(strURL, Len(strURL) - 1)
>
> >>End Function
>
> >>RaceCardhttp://www.youtube.com/watch?v=3D1FQtN2NbGv8
>
> > (I'm not sure if the message I just sent you actually sent, so I'll
> > post again)
> > Could you explain this step in more detail please?
>
> > "I pass strType to MakeUrl. =A0If blank, it creates the URL for
> > displaying
> > a map of the location specified. =A0If strType =3D "Driving" then I
> > create
> > the URL for driving instructions. =A0It opens InternetExplorer to the
> > URL. "
>
> > Sorry, I truly am a begginer.
>
> Let's say you have a form with 4 textbox fields name; address, city,
> state, zip. =A0There's also 1 command button to call GoogleMaps...name it
> CommandMap. =A0Take my code and post it in the form's code module. =A0If
> your field names are NOT address, city, state, zip then change those
> names in my code to the names of your textbox controls.
>
> In the OnClick event of the code module you would enter
> =A0 =A0 =A0 =A0 MakeUrl " "
>
> You can check this out easily enough. =A0Create a table with the fields
> address, city, state, zip. =A0Save the table. =A0Open it and add a record.=

>
> Now using the form wizard (Forms/New/Wizard) create a form for that
> table. =A0Open it in design mode and add the command button CommandMap to
> your form and in the OnClick of event CommandMap enter
> =A0 =A0 =A0 =A0 MakeUrl " "
>
> Save the form. =A0Then open it and see if it works.
>
> Now if I had 4 more textboxes on the form; toaddress, tocity, tostate,
> tozip then I have a starting address and an ending address. =A0I could get=

> driving instructions by entering in the OnClick of event of CommandMap
> =A0 =A0 =A0 =A0 MakeUrl "Driving"- Hide quoted text -
>
> - Show quoted text -

Okay, I did everything you said exactly and and error message comes up
that says "MS Access can't find the macro 'MakeURL "" .'

Re: Help with Google Maps

am 23.04.2008 17:56:02 von Salad

pagina wrote:
> On Apr 22, 5:23 pm, Salad wrote:
>
>>pagina wrote:
>>
>>>On Apr 22, 10:19 am, Salad wrote:
>>
>>>>pagin...@gmail.com wrote:
>>
>>>>>I am a true beginner in Access and coding.
>>
>>>>>I am creating a database with facility information and I want to use
>>>>>the address of a specific facility to display a map on my form or at
>>>>>least open a new window with the address already plugged into Google
>>>>>maps.
>>
>>>>>I don't even know where to begin. Can someone please help?
>>
>>>>These 2 routines might help. I have a form with 4 fields; City, State,
>>>>Address, and ZipCode. MakeUrl calls routine CreateUrl that makes the
>>>>URL for googlemaps.
>>
>>>>On my form I also suppled 4 more fields; ToCity, ToState, ToAddress, and
>>>>ToZipCode if I want driving instructions.
>>
>>>>I pass strType to MakeUrl. If blank, it creates the URL for displaying
>>>>a map of the location specified. If strType = "Driving" then I create
>>>>the URL for driving instructions. It opens InternetExplorer to the URL.
>>
>>>>If the fields on your form match my field names it's ready to run as-is.
>>>> If not, change the field names in the code below to match your textbox
>>>>field names.
>>
>>>>Then create a command button. In the OnClick event enter
>>>> MakeUrl "" 'no driving instructions
>>>>or
>>>> MakeUrl "Driving" 'driving instructions.
>>
>>>>Private Sub MakeURL(strType As String)
>>>>On Error GoTo Err_MakeURL
>>>> Dim strURL As String
>>>> Dim objBrowser As Object
>>
>>>> If IsNull(Me.City) Or IsNull(Me.State) Then
>>>> MsgBox "You need to supply at least the city and state."
>>>> Me.City.SetFocus
>>>> Else
>>>> strURL = CreateUrl(Me.Address, Me.City, Me.State, Me.ZipCode)
>>
>>>> If strType = "Driving" Then
>>>> strURL = strURL & "+" & "to" & "+" &
>>>>CreateUrl(Me.ToAddress, Me.ToCity, Me.ToState, Me.ToZipCode)
>>>> End If
>>>> strURL = "http://maps.google.com/maps?q=" & strURL &
>>>>"&iwloc=A&hl=en"
>>
>>>> Dim obj As Object
>>>> Set obj = CreateObject("InternetExplorer.Application")
>>>> With obj
>>>> .Navigate2 strURL
>>>> .Visible = True
>>>> End With
>>>> Set obj = Nothing
>>>> End If
>>>>Exit_MakeURL:
>>>> Exit Sub
>>
>>>>Err_MakeURL:
>>>> MsgBox Err.Description
>>>> Resume Exit_MakeURL
>>
>>>>End Sub
>>>>Private Function CreateUrl(strAddress As Variant, strCity As String,
>>>>strState As String, strZip As Variant) As String
>>>> 'generate the URL to pass to Google in browser.
>>>> Dim strURL As String
>>>> Dim strOrig As String
>>>> Dim intPos As Integer
>>
>>>> If Not IsNull(strAddress) Then
>>>> strOrig = strAddress
>>>> Do While True
>>>> If strOrig <> "" Then
>>>> intPos = InStr(strOrig, " ")
>>>> If intPos > 0 Then
>>>> strURL = strURL & Left(strOrig, intPos - 1) & "+"
>>>> strOrig = LTrim(Mid(strOrig, intPos + 1))
>>>> Else
>>>> strURL = strURL & strOrig & "+"
>>>> Exit Do
>>>> End If
>>>> Else
>>>> Exit Do
>>>> End If
>>>> Loop
>>>> End If
>>>> strURL = strURL & strCity & "+" & strState & "+"
>>>> If Not IsNull(strZip) Then strURL = strURL & strZip & "+"
>>
>>>> CreateUrl = Left(strURL, Len(strURL) - 1)
>>
>>>>End Function
>>
>>>>RaceCardhttp://www.youtube.com/watch?v=1FQtN2NbGv8
>>
>>>(I'm not sure if the message I just sent you actually sent, so I'll
>>>post again)
>>>Could you explain this step in more detail please?
>>
>>>"I pass strType to MakeUrl. If blank, it creates the URL for
>>>displaying
>>>a map of the location specified. If strType = "Driving" then I
>>>create
>>>the URL for driving instructions. It opens InternetExplorer to the
>>>URL. "
>>
>>>Sorry, I truly am a begginer.
>>
>>Let's say you have a form with 4 textbox fields name; address, city,
>>state, zip. There's also 1 command button to call GoogleMaps...name it
>>CommandMap. Take my code and post it in the form's code module. If
>>your field names are NOT address, city, state, zip then change those
>>names in my code to the names of your textbox controls.
>>
>>In the OnClick event of the code module you would enter
>> MakeUrl " "
>>
>>You can check this out easily enough. Create a table with the fields
>>address, city, state, zip. Save the table. Open it and add a record.
>>
>>Now using the form wizard (Forms/New/Wizard) create a form for that
>>table. Open it in design mode and add the command button CommandMap to
>>your form and in the OnClick of event CommandMap enter
>> MakeUrl " "
>>
>>Save the form. Then open it and see if it works.
>>
>>Now if I had 4 more textboxes on the form; toaddress, tocity, tostate,
>>tozip then I have a starting address and an ending address. I could get
>>driving instructions by entering in the OnClick of event of CommandMap
>> MakeUrl "Driving"- Hide quoted text -
>>
>>- Show quoted text -
>
>
> Okay, I did everything you said exactly and and error message comes up
> that says "MS Access can't find the macro 'MakeURL "" .'

I wrote "Take my code and post it in the form's code module.". Did you
copy/paste my code for MakeUrl and CreateUrl into the form's code module?

If you open the property sheet for the command button CommandMap, select
Events, click on the OnClick row. There'll be a button with ... as
its caption on the far right of the row. Press on it...one of the
options is Code. Select Code and put the
MakeUrl " "
line between the Sub and End Sub lines.

We're getting close!

Why Aye Man
http://www.youtube.com/watch?v=0NHmpOER-sA

Re: Help with Google Maps

am 23.04.2008 19:42:23 von pagina21

On Apr 23, 10:56=A0am, Salad wrote:
> pagina wrote:
> > On Apr 22, 5:23 pm, Salad wrote:
>
> >>pagina wrote:
>
> >>>On Apr 22, 10:19 am, Salad wrote:
>
> >>>>pagin...@gmail.com wrote:
>
> >>>>>I am a true beginner in Access and coding.
>
> >>>>>I am creating a database with facility information and I want to use
> >>>>>the address of a specific facility to display a map on my form or at
> >>>>>least open a new window with the address already plugged into Google
> >>>>>maps.
>
> >>>>>I don't even know where to begin. Can someone please help?
>
> >>>>These 2 routines might help. =A0I have a form with 4 fields; City, Sta=
te,
> >>>>Address, and ZipCode. =A0MakeUrl calls routine CreateUrl that makes th=
e
> >>>>URL for googlemaps.
>
> >>>>On my form I also suppled 4 more fields; ToCity, ToState, ToAddress, a=
nd
> >>>>ToZipCode if I want driving instructions.
>
> >>>>I pass strType to MakeUrl. =A0If blank, it creates the URL for display=
ing
> >>>>a map of the location specified. =A0If strType =3D "Driving" then I cr=
eate
> >>>>the URL for driving instructions. =A0It opens InternetExplorer to the =
URL.
>
> >>>>If the fields on your form match my field names it's ready to run as-i=
s.
> >>>> If not, change the field names in the code below to match your textbo=
x
> >>>>field names.
>
> >>>>Then create a command button. =A0In the OnClick event enter
> >>>> =A0 =A0 =A0 MakeUrl "" =A0 'no driving instructions
> >>>>or
> >>>> =A0 =A0 =A0 MakeUrl "Driving" =A0'driving instructions.
>
> >>>>Private Sub MakeURL(strType As String)
> >>>>On Error GoTo Err_MakeURL
> >>>> =A0 =A0Dim strURL As String
> >>>> =A0 =A0Dim objBrowser As Object
>
> >>>> =A0 =A0If IsNull(Me.City) Or IsNull(Me.State) Then
> >>>> =A0 =A0 =A0 =A0MsgBox "You need to supply at least the city and state=
.."
> >>>> =A0 =A0 =A0 =A0Me.City.SetFocus
> >>>> =A0 =A0Else
> >>>> =A0 =A0 =A0 =A0strURL =3D CreateUrl(Me.Address, Me.City, Me.State, Me=
..ZipCode)
>
> >>>> =A0 =A0 =A0 =A0If strType =3D "Driving" Then
> >>>> =A0 =A0 =A0 =A0 =A0 =A0strURL =3D strURL & "+" & "to" & "+" &
> >>>>CreateUrl(Me.ToAddress, Me.ToCity, Me.ToState, Me.ToZipCode)
> >>>> =A0 =A0 =A0 =A0End If
> >>>> =A0 =A0 =A0 =A0strURL =3D "http://maps.google.com/maps?q=3D" & strURL=
&
> >>>>"&iwloc=3DA&hl=3Den"
>
> >>>> =A0 =A0 =A0 =A0Dim obj As Object
> >>>> =A0 =A0 =A0 =A0Set obj =3D CreateObject("InternetExplorer.Application=
")
> >>>> =A0 =A0 =A0 =A0With obj
> >>>> =A0 =A0 =A0 =A0 =A0 =A0.Navigate2 strURL
> >>>> =A0 =A0 =A0 =A0 =A0 =A0.Visible =3D True
> >>>> =A0 =A0 =A0 =A0End With
> >>>> =A0 =A0 =A0 =A0Set obj =3D Nothing
> >>>> =A0 =A0End If
> >>>>Exit_MakeURL:
> >>>> =A0 =A0Exit Sub
>
> >>>>Err_MakeURL:
> >>>> =A0 =A0MsgBox Err.Description
> >>>> =A0 =A0Resume Exit_MakeURL
>
> >>>>End Sub
> >>>>Private Function CreateUrl(strAddress As Variant, strCity As String,
> >>>>strState As String, strZip As Variant) As String
> >>>> =A0 =A0'generate the URL to pass to Google in browser.
> >>>> =A0 =A0Dim strURL As String
> >>>> =A0 =A0Dim strOrig As String
> >>>> =A0 =A0Dim intPos As Integer
>
> >>>> =A0 =A0If Not IsNull(strAddress) Then
> >>>> =A0 =A0 =A0 =A0strOrig =3D strAddress
> >>>> =A0 =A0 =A0 =A0Do While True
> >>>> =A0 =A0 =A0 =A0 =A0 =A0If strOrig <> "" Then
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intPos =3D InStr(strOrig, " ")
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0If intPos > 0 Then
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strURL =3D strURL & Left(strOr=
ig, intPos - 1) & "+"
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strOrig =3D LTrim(Mid(strOrig,=
intPos + 1))
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Else
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strURL =3D strURL & strOrig & =
"+"
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit Do
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0End If
> >>>> =A0 =A0 =A0 =A0 =A0 =A0Else
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit Do
> >>>> =A0 =A0 =A0 =A0 =A0 =A0End If
> >>>> =A0 =A0 =A0 =A0Loop
> >>>> =A0 =A0End If
> >>>> =A0 =A0strURL =3D strURL & strCity & "+" & strState & "+"
> >>>> =A0 =A0If Not IsNull(strZip) Then strURL =3D strURL & strZip & "+"
>
> >>>> =A0 =A0CreateUrl =3D Left(strURL, Len(strURL) - 1)
>
> >>>>End Function
>
> >>>>RaceCardhttp://www.youtube.com/watch?v=3D1FQtN2NbGv8
>
> >>>(I'm not sure if the message I just sent you actually sent, so I'll
> >>>post again)
> >>>Could you explain this step in more detail please?
>
> >>>"I pass strType to MakeUrl. =A0If blank, it creates the URL for
> >>>displaying
> >>>a map of the location specified. =A0If strType =3D "Driving" then I
> >>>create
> >>>the URL for driving instructions. =A0It opens InternetExplorer to the
> >>>URL. "
>
> >>>Sorry, I truly am a begginer.
>
> >>Let's say you have a form with 4 textbox fields name; address, city,
> >>state, zip. =A0There's also 1 command button to call GoogleMaps...name i=
t
> >>CommandMap. =A0Take my code and post it in the form's code module. =A0If=

> >>your field names are NOT address, city, state, zip then change those
> >>names in my code to the names of your textbox controls.
>
> >>In the OnClick event of the code module you would enter
> >> =A0 =A0 =A0 =A0MakeUrl " "
>
> >>You can check this out easily enough. =A0Create a table with the fields
> >>address, city, state, zip. =A0Save the table. =A0Open it and add a recor=
d.
>
> >>Now using the form wizard (Forms/New/Wizard) create a form for that
> >>table. =A0Open it in design mode and add the command button CommandMap t=
o
> >>your form and in the OnClick of event CommandMap enter
> >> =A0 =A0 =A0 =A0MakeUrl " "
>
> >>Save the form. =A0Then open it and see if it works.
>
> >>Now if I had 4 more textboxes on the form; toaddress, tocity, tostate,
> >>tozip then I have a starting address and an ending address. =A0I could g=
et
> >>driving instructions by entering in the OnClick of event of CommandMap
> >> =A0 =A0 =A0 =A0MakeUrl "Driving"- Hide quoted text -
>
> >>- Show quoted text -
>
> > Okay, I did everything you said exactly and and error message comes up
> > that says "MS Access can't find the macro 'MakeURL "" .'
>
> I wrote "Take my code and post it in the form's code module.". =A0Did you
> copy/paste my code for MakeUrl and CreateUrl into the form's code module?
>
> If you open the property sheet for the command button CommandMap, select
> =A0 Events, click on the OnClick row. =A0There'll be a button with ... as
> its caption on the far right of the row. =A0Press on it...one of the
> options is Code. =A0Select Code and put the
> =A0 =A0 =A0 =A0 MakeUrl " "
> line between the Sub and End Sub lines.
>
> We're getting close!
>
> Why Aye Manhttp://www.youtube.com/watch?v=3D0NHmpOER-sA

Okay, now I get a Compile Error: Expected End Sub