473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open MAP, set PushPin, add lat./lng of pushpin to recordset ?

32 New Member
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).
Jul 11 '18 #1
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:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public Declare Sub keybd_event Lib "user32" ( _
  5.     ByVal bVk As Byte, _
  6.     ByVal bScan As Byte, _
  7.     ByVal dwFlags As Long, _
  8.     ByVal dwExtraInfo As Long)
  9.  
  10. Declare Function GetKeyState Lib "user32.dll" ( _
  11.     ByVal nVirtKey As Long) As Integer
  12.  
  13. Private Const vk_Tab = &H9 'TAB key
  14. Private Const vk_Shift = &H10 'SHIFT key
  15. Private Const vk_Control = &H11 'CTRL key
  16. Private Const vk_KEYUP = &H2 'indicates the key being released
  17. Private Const vk_C = 67
  18.  
  19. Public Function vkC()
  20.     keybd_event vk_C, 1, 0, 0
  21. End Function
  22. Public Function vkShift()
  23.     keybd_event vk_Shift, 1, 0, 0
  24. End Function
  25. Public Function vkShiftUp()
  26.     keybd_event vk_Shift, 1, vk_KEYUP, 0
  27. End Function
  28. Public Function vkTab()
  29.     keybd_event vk_Tab, 1, 0, 0
  30. End Function
  31. Public Function vkCtl()
  32.     keybd_event vk_Control, 1, 0, 0
  33. End Function
  34. Public Function vkCtlUp()
  35.     keybd_event vk_Control, 1, vk_KEYUP, 0
  36. End Function
Then, in your Form, using a Command Button, place this code in the OnClick Event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLatLong_Click()
  2. On Error GoTo EH
  3.     Dim objData     As New MSForms.DataObject
  4.     Dim strTemp     As String
  5.  
  6.     AppActivate "Google Maps", False
  7.     vkShift
  8.     vkTab
  9.     PauseEvent 0.25
  10.     vkShift
  11.     vkTab
  12.     vkShiftUp
  13.     PauseEvent 0.25
  14.     vkCtl
  15.     vkC
  16.     vkCtlUp
  17.     PauseEvent 0.25
  18.     objData.GetFromClipboard
  19.     strTemp = objData.GetText()
  20.     Debug.Print strTemp
  21.  
  22.     Exit Sub
  23. EH:
  24.     MsgBox "There was an error getting the Lat/Long!" & vbCrLf & vbCrLf & _
  25.         "Error: " & Err.Number & vbCrLf & _
  26.         "Description: " & Err.Description & vbCrLf & vbCrLf & _
  27.         "Please contact your Database Administrator.", vbCritical, "WARNING!"
  28.     Exit Sub
  29. End Sub
  30.  
  31. Public Function PauseEvent(ByVal Delay As Double)
  32.     Dim dblEndTime As Double
  33.  
  34.     dblEndTime = Timer + Delay
  35.     Do While Timer < dblEndTime
  36.         DoEvents
  37.     Loop
  38. 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!
Jul 11 '18 #2
PhilOfWalton
1,430 Recognized Expert Top Contributor
@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
Jul 11 '18 #3
mminieri
32 New Member
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?
Jul 12 '18 #4
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.
Jul 12 '18 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2289
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...
6
22175
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. ...
3
3867
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...
18
6123
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 ...
36
4413
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...
9
24280
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...
8
2340
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...
1
2268
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...
4
2688
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...
0
7199
marktang
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,...
0
7273
Oralloy
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,...
0
7322
jinu1996
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...
1
6982
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...
1
5000
isladogs
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...
0
4667
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...
0
3161
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...
0
1501
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 ...
0
374
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.