473,657 Members | 2,507 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 1794
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\SysW OW64\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
2293
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 fine I think) that will say "I'm sorry but the data you requested cannot be found" or something along those lines.... This code is on an archive page I have on my company's intranet....The end result is to show 3 records at a time pulled from an...
6
22179
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. I'm somewhat of a rookie when it comes to working with Recordsets, but this is what I'm trying to do: Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim qdf As DAO.QueryDef
3
3880
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 the problem, I thought of using OPENARGS to pass information to the form being opened (instead of using WHERE). In the parent form, I have generated a RecordSet (RS) with the information
18
6142
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 src = "SELECT Count(*) FROM reviewer INNER JOIN pp_officer " & _ "ON reviewer.reviewer_id = pp_officer.ppo_rev_id " & _ "WHERE rev_login = 'EllisonL'" Set rL = CurrentProject.Connection.Execute(src, , adCmdText)
36
4460
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 dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
9
24311
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 to win2003 using SQL 2003 I get the above error when my asp page does teh line: Rs.absolutepage = intCurrentPage I tested teh value of intCurrent page and teh value is 1.
8
2346
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 slow.... I am thinking that there might be another way to do it... maybe faster. Is there a way to filter it as I open it ? I'm using the following simple code:
1
2296
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 the function should return 153. Here is the basic code... Function FirstOpen() As Integer Dim db As DAO.Database Dim rs As DAO.Recordset
4
2708
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 code that calculates the total price, depending on number of units, currently what the code does is set the price like so - if qty 1 then £99+VAT if qty equall to or greater than 2 and equall to or less than 9 then price =
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
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 we have to send another system
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1611
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.