I have a database project (in MS Access 2016) and wish to add a mapping feature with the following functionality (via VBA is preferred);
1 – Create a FORM that includes display of a street map of a specific small city overall view (I can get the desired starting URL from Google or Bing maps). This can fill on Open or via a command button.
2 – The user manipulates that map’s controls in order to locate a target point that they desire, and manually MARK (such as by pushpin) that point.
3 – After marking the point they can press a command button which will then acquire the latitude and longitude of the point so marked (pushpin) and store that data in the current recordset. If that marked map image can be stored as a .jpg or similar, that would be a “bonus”.
4 – On the REPORT associated with that recordset, I would like to include a subREPORT that is an image of that map showing that pushpin…… either using the SAVED .jpg image OR created dynamically at Preview/Print so that it appears in the printed REPORT (whichever method is easier to code).
4 1783 twinnyfo 3,653
Recognized Expert Moderator Specialist
OK - so normally we don't just post a full solution, but trying to describe this one step by step would be nearly impossible.
First, in your VBA Editor, go to Tools, References..., Browse: C:\Windows\SysWOW64\FM20.DLL and add it to your references. It may be in a different location on your machine.
Next, create a new stand alone module named modKeyStrokes : - Option Compare Database
-
Option Explicit
-
-
Public Declare Sub keybd_event Lib "user32" ( _
-
ByVal bVk As Byte, _
-
ByVal bScan As Byte, _
-
ByVal dwFlags As Long, _
-
ByVal dwExtraInfo As Long)
-
-
Declare Function GetKeyState Lib "user32.dll" ( _
-
ByVal nVirtKey As Long) As Integer
-
-
Private Const vk_Tab = &H9 'TAB key
-
Private Const vk_Shift = &H10 'SHIFT key
-
Private Const vk_Control = &H11 'CTRL key
-
Private Const vk_KEYUP = &H2 'indicates the key being released
-
Private Const vk_C = 67
-
-
Public Function vkC()
-
keybd_event vk_C, 1, 0, 0
-
End Function
-
Public Function vkShift()
-
keybd_event vk_Shift, 1, 0, 0
-
End Function
-
Public Function vkShiftUp()
-
keybd_event vk_Shift, 1, vk_KEYUP, 0
-
End Function
-
Public Function vkTab()
-
keybd_event vk_Tab, 1, 0, 0
-
End Function
-
Public Function vkCtl()
-
keybd_event vk_Control, 1, 0, 0
-
End Function
-
Public Function vkCtlUp()
-
keybd_event vk_Control, 1, vk_KEYUP, 0
-
End Function
Then, in your Form, using a Command Button, place this code in the OnClick Event: - Private Sub cmdLatLong_Click()
-
On Error GoTo EH
-
Dim objData As New MSForms.DataObject
-
Dim strTemp As String
-
-
AppActivate "Google Maps", False
-
vkShift
-
vkTab
-
PauseEvent 0.25
-
vkShift
-
vkTab
-
vkShiftUp
-
PauseEvent 0.25
-
vkCtl
-
vkC
-
vkCtlUp
-
PauseEvent 0.25
-
objData.GetFromClipboard
-
strTemp = objData.GetText()
-
Debug.Print strTemp
-
-
Exit Sub
-
EH:
-
MsgBox "There was an error getting the Lat/Long!" & vbCrLf & vbCrLf & _
-
"Error: " & Err.Number & vbCrLf & _
-
"Description: " & Err.Description & vbCrLf & vbCrLf & _
-
"Please contact your Database Administrator.", vbCritical, "WARNING!"
-
Exit Sub
-
End Sub
-
-
Public Function PauseEvent(ByVal Delay As Double)
-
Dim dblEndTime As Double
-
-
dblEndTime = Timer + Delay
-
Do While Timer < dblEndTime
-
DoEvents
-
Loop
-
End Function
With Google maps, I have been unable to place a push pin and have the system recognize that push pin. However, with this method, the user can zoon in to wherever they want and Google Maps will save that view for future use.
ALso note, that this code is finicky at best and frustrating at worst. The user must be in Google Maps, with no bells and whistles shown and have most recently clicked, or double-clicked on the map itself.
Now, keep in mind that the only thing that this lengthy code is doing is copying and pasting the URL from Google Maps, which is just as easy for the user to do and using a Button to do it. But, this methodology could be used for some other features in your projects.
(Try to) Enjoy.
Hope this hepps!
@Twinnyfo.
If it's any help, if you left click twice on Google Maps, you get a pushpin and box with an address with lat & long.
If you right click on the box, and choose "inspect" you get a page of HTML that can be read to give the Lat & Long and address.
I have a very complex routine that can read a web page of share prices, and this may well adapt to read these values.
Phil
Thanks gentlemen as always. After I set the pushpin, then press the command button, I am not able to see where - if anywhere - the lat & lng of the pin was saved. Should there be somewhere in the code you posted to identify the table fields where these are to be stored?
zmbd 5,501
Recognized Expert Moderator Expert
mminieri:
The code that twinnyfo posted is not saving the information at all instead it's sending it to the immediate window at Line 20 Debug.Print strTemp press <ctrl><g> to open the VBA editor and the immediate window - now go back the main Access interface (leave the VBE open), open your form, etc...
Once you click on the command button bring your VBE back to the front and you will see the string that twinnyfo mentions below his code block.
Also take note that he states that the Lat/Long is not being pulled using this code; instead, the url related to the map view is being pulled.
Mminieri, normally we don't provide full code or application development; however, a quick search of the internet found this: http://www.alfainfo.it/gps-latitude-...rosoft-access/ I believe that this is somewhat close to what it is that you are attempting to do so it may be a good starting point for use to work with - It's not exact but maybe close.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dmiller23462 |
last post by:
My brain is nuked....Can anybody tell me right off the bat what is
wrong with this code? Along with any glaring errors, please let me
know the syntax to display a message (Response.Write would be...
|
by: deko |
last post by:
I have several stored queries that provide views based on user selection -
selection criteria is stored in strPxSx, and the query called would then be
"qrySearch24" or "qrySearch19", for example.
...
|
by: Lyn |
last post by:
Hi,
I have been experiencing a problem passing a LIKE statement in the WHERE
argument of a DoCmd.Openform statement. I have posted that issue
separately.
However, in an attempt to work around...
|
by: Darryl Kerkeslager |
last post by:
When I open an ADO Recordset, I close it. However, it seems that there may
be some difference in this manner of opening a Recordset:
Dim rL As ADODB.Recordset
Set rL = New ADODB.Recordset
...
|
by: kjvt |
last post by:
Based on a prior posting, I've written a function to convert a
recordset to a dataview. The first call to the function for a given
recordset works perfectly, but the second call always returns a...
| |
by: Johnfli |
last post by:
ADODB.Recordset error '800a0cb3'
Current Recordset does not support bookmarks. This may be a limitation of
the provider or of the selected cursortype.
I am moving my webserver from NT4 using SQL...
|
by: Radu |
last post by:
Hi,
I have the following problem: I open a recordset based on excel/csv
files, but then I need to filter (in code) in order to extract only
data pertaining to a specific person. This code is...
|
by: William Hardin |
last post by:
I am writing a function in which I need to open a sorted recordset. I am
using a SQL statemenet in the db.OpenRecordset line, but it is only
returning one record, when executing the query outside...
|
by: =?Utf-8?B?R1ROMTcwNzc3?= |
last post by:
Hi Guys, thanks for your help yesterday, I've got one more question, then I
think I'm done for now,...
Is it possible to insert recordset data in a javascript, for instance I have
a javascript...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| | |