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 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 : - 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 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...
|
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
|
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
|
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)
|
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
| |
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.
|
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:
|
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
|
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 =
|
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,...
|
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...
| |
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...
|
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...
|
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();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |