By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 1,029 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

Using Google Maps In MS Access

P: n/a
Have you ever wanted to add the great features inherent in Google Maps?
Here is how you do it.

==============
== STEP ONE ==
==============

Create a new MS Access form called frmGoogleMap. Size the form to your
liking...

On the blank form, go to the "Insert" menu and select "ActiveX
Control..."

When the selection screen appears, choose "Microsoft Web Browser".

Once the control object has been placed on your form, resize the
control object WITHOUT SAVING THE FORM. The reason for this? Once you
save the form, if you want to resize after saving you have to delete
the control object and re-insert a new Microsoft Web Browser ActiveX
control object each time you want to resize it.
In this example, I have named the control object WebBrowser0.

I recommend inserting a command button named cmdClose for testing
purposes.

Once you have the Design View finished,...

a.) Set the TimerInterval for the form to 1000
b.) Go to the View menu option.
c.) Click on Code.
d.) In the Code Module for the form, insert the following code.

=<BEGIN>========================================== ===============

Option Compare Database

Private Sub cmdClose_Click()

Me.TimerInterval = 1000
MyAssigned = False
Set objBrowser = Nothing
DoCmd.Hourglass False
DoCmd.Close acForm, "frmGoogleMap", acSaveNo

End Sub

Private Sub Form_Timer()

'Declare variables.
Dim objBrowser As Object

'Set variables.
Set objBrowser = Me.WebBrowser0

If MyAssigned = False Then
DoCmd.Hourglass True
With Me.WebBrowser0
.Navigate MyGoogleMapURL
Do Until .ReadyState <> 3
DoEvents
Loop
DoEvents
Do Until .ReadyState = 4
DoEvents
Loop
DoEvents
MyAssigned = True
End With
DoCmd.Hourglass False
End If

End Sub

=<END>============================================ ===============

Save and close the new form naming it "frmGoogleMap".

==============
== STEP TWO ==
==============

Go to the Modules section of your MS Access database, and click New and
insert the following code.

=<BEGIN>========================================== ===============

Option Compare Database

Global MyAssigned As Boolean
Global MyGoogleMapURL As String

=<END>============================================ ===============

Save and close the new module naming it "Google Variables".
At this point, I will show you how Google Maps structures the URL that
retrieves a requested map.

Let's say you want to search for :

John Smith
111 West Gable Lane
Dayton, OH 45410

When you go to Google Maps at http://maps.google.com, you type in the
address and Google goes to...

"http://maps.google.com/maps?q=111+West+Gable+Lane+Dayton+OH+45410&iwloc=A &hl=en"

Now to pass this value to your new form, set your MyGoogleMapURL
variable to the above URL and open the new form like this:

MyGoogleMapURL =
"http://maps.google.com/maps?q=111+West+Gable+Lane+Dayton+OH+45410&iwloc=A &hl=en"
DoCmd.OpenForm "frmGoogleMap", acNormal

Obviously, you can parse the string value of the URL to any address of
your choosing.

Programmer's Note(s) And/Or Warnings:

If you're connecting to your new Google Maps form through a Citrix
connection, the opening of the Microsoft Web Browser control will crash
your MS Access database. This is because Google Maps will turn your
SpeedScreen setting on in Citrix, even if you have it set to Off, and
the combined running of both creates a GPF error.

You CAN, however, use a standard Remote Desktop Connection(RDC) or a
VNC connection with no resulting crashing of MS Access.

For additional business purposes, you can also have your MS Access
application target different types of businesses nearby (Example :
Schools) just by setting the URL string value to something like...

"http://maps.google.com/maps?q=schools+loc%3A+111+West+Gable+Lane+Dayton+O H+45410&f=l&hl=en"

I hope this helps you in your development process.

If you have any questions, feel free to contact me at:

Sean Dorman
se*********@yahoo.com

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I almost forgot to mention...the difference between showing the map in
"Satellite" view, as opposed to the "Map" view, is in how you end the
URL sent to the Google Map form you have created.

The "Map" view URL ends like this...
"...+fresno+ca+93711&iwloc=A&hl=en"

The "Satellite" view URL ends like this...
"...+fresno+ca+93711&t=k&iwloc=A&hl=en"

Again, I hope this helps.

Sean Dorman
se*********@yahoo.com

Nov 13 '05 #2

P: n/a
Haven't tried it yet, but the concept sounds very good.

Thanks.

--
Darryl Kerkeslager
Nov 13 '05 #3

P: n/a

Sean wrote:
Once the control object has been placed on your form, resize the
control object WITHOUT SAVING THE FORM. The reason for this? Once you
save the form, if you want to resize after saving you have to delete
the control object and re-insert a new Microsoft Web Browser ActiveX
control object each time you want to resize it.


I find that this code sizes (for width) my browser control quite
satisfactorily:

Private Sub Form_Open(Cancel As Integer)
Me.wbHDSBHelp.Width = Me.Width
End Sub

I think we are talking about the same control? Perhaps, I am
misunderstanding.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.