Results 1 to 12 of 12
  1. #1
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119

    Working with Location API (Windows 8)

    Hello all,



    I am trying to toy around with the built-in GPS chip in an HP tablet that has Access 2013 installed. I've been trying to test it out by at least first getting to see if I can get coordinates. The built-in chip uses LocationAPI.dll, and so I have loaded that on to MS Access references. After perusing through the objects list and trying to make sense of it, this is how far I've gotten:

    Code:
    Option Compare Database
    Option Explicit
    
    Public Function testGPS() As String
    
    Dim Lat, Lng as Double
    Dim Display as LatLongReportFactory
    
    Set Display = New LatLongReportFactory
    
    Lat = Display.LatLongReport.Latitude
    Lng = Display.LatLongReport.Longitude
    
    testGPS = Lat & "," & Lng
    
    End Function
    When executing the function through the Immediate window, it throws the error:

    Run-time error '-2147024664 (800700e8)': Method 'LatLongReport' of object 'ILatLongReportFactory' failed.

    When debugging, it highlights the line
    Code:
    Lat = Display.LatLongReport.Latitude
    However, I don't change anything and just hit "Continue[F5]" and the function returns the proper GPS coordinates without a hitch. This is my first time trying to use Access in conjunction with things other than the typical forms, reports, etc., so my VBA knowledge is limited, but I figured this would be a great learning experience lol

    Any sort of help would be greatly appreciated!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The DLL file probably does not understand what an Access Variant is.

    Instead of
    Dim Lat, Lng as Double
    try
    Dim Lat as Double, Lng as Double

    The former defaults Lat to data type Variant

  3. #3
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    Magnificent! So simple... So just to clarify, I was under the wrong assumption that the syntax I used of declaring multiple variables and setting the type can be done the way I did above. What would be the proper syntax to do so?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    In Access you must explicitly Dim variables

    eg
    Dim Lat as Double, Lng as Double or
    Dim Lat as Double
    Dim Lng as Double

  5. #5
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    Ah thank you... Guess I'll suck it up with the extra keystrokes haha, thanks again!

  6. #6
    baumschaum is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    2
    Hello,

    I bumped into the same problem as thebigthing313 a few years ago. I'm trying to get GPS-coordinates from my Windows 10 tablet with Access 2016.
    Using the code above (with the explicitly declarating the variables) I'm still getting the runtime-error: "

    Run-time error '-2147024664 (800700e8)': Method 'LatLongReport' of object 'ILatLongReportFactory' failed."

    The error is also in the same line (marked bold):

    Code:
    Function getGPScoordinates()
      Dim Lat As Double
      Dim Lng As Double
      
        Dim disp As LatLongReportFactory
        Set disp = New LatLongReportFactory
        
        Sleep 100
        Lat = disp.LatLongReport.Latitude
        Lng = disp.LatLongReport.Longitude
        getGPScoordinates = Lat & "," & Lng
        
    End Function
    I added the "sleep 100" because it worked for this guy: https://social.msdn.microsoft.com/Fo...orum=accessdev
    It doesn't work for me though...

    Does anyone know if there's a major difference between Access 2016 and Access 2010 or Windows 10 and Windows 7 that would result in still getting this error?
    Any suggestion is highly appreciated!

    Thanks in advance!

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    I have a free utility on my website to get your current location http://www.mendipdatasystems.co.uk/g...ion/4594365395
    Th code isn't the same but the functionality should be similar.

    Also check the various caveats needed to get any similar code working in Windows 10.
    There was a bug introduced with version 1803 though fixed in version 1809 for many users.

    EDIT: I just tried the code listed using Windows 10 and got the same error.
    If you read this article, you will see the situation has changed for Windows 10: https://docs.microsoft.com/en-us/uwp...es.Geolocation
    It looks like you need to use the new WindowsGeolocation.dll instead but I got an error when I tried to add this
    Needs more research. Good luck
    Let us know if you work out the solution
    Last edited by isladogs; 03-27-2019 at 04:58 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    baumschaum, I have not logged on to this site in quite some time, but I had to reply because I found it funny that I'm "this guy" from the link you shared on the MSDN forums haha

    I have long since abandoned using Microsoft Access to retrieve coordinates from those tablets, but I hope you have better luck than me.

  9. #9
    baumschaum is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    2
    Quote Originally Posted by isladogs View Post
    I have a free utility on my website to get your current location http://www.mendipdatasystems.co.uk/g...ion/4594365395
    Th code isn't the same but the functionality should be similar.

    Also check the various caveats needed to get any similar code working in Windows 10.
    There was a bug introduced with version 1803 though fixed in version 1809 for many users.

    EDIT: I just tried the code listed using Windows 10 and got the same error.
    If you read this article, you will see the situation has changed for Windows 10: https://docs.microsoft.com/en-us/uwp...es.Geolocation
    It looks like you need to use the new WindowsGeolocation.dll instead but I got an error when I tried to add this
    Needs more research. Good luck
    Let us know if you work out the solution
    Thanks for your help. I tried loading the WindwosGeolocation.dll into my Access-Database but I'm getting an error. No clue why it appears in that list because I can't seem to find it in the Windows Directory.

    However, I realized that the given code IS working but not on the first try. After executing the function I keep getting that run-time error with a mark on the mentioned line. After waiting for about 5 seconds and continuing the execution of the code with F8 it works! It actually gives me my GPS-coordinates!

    It seems like the code is working but needs some time to Launch the GPS-module or whatever in order to give out the coordinates. In the meantime it just gives out that run-time error. If this is the case, why doesn't it work on the second try as the GPS-module should be running, right?

    I'm not an expert in programming but in this case I don't think thats the reason why I'm so confused haha.

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by thebigthing313 View Post
    I have long since abandoned using Microsoft Access to retrieve coordinates from those tablets, but I hope you have better luck than me.
    Have a look at my Get Geolocation app - see first link in post #7 - it uses a completely different approach which works well.
    That doesn't require the LocationAPI (which I also can't get to work in Windows 7 or 10)
    I've also tried using the Windows Geolocation library (geolocation.dll) .... but can't even enable that library for some reason
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Post 9 was moderated, I'm posting to trigger email notifications.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by baumschaum View Post
    Thanks for your help. I tried loading the WindwosGeolocation.dll into my Access-Database but I'm getting an error. No clue why it appears in that list because I can't seem to find it in the Windows Directory.

    However, I realized that the given code IS working but not on the first try. After executing the function I keep getting that run-time error with a mark on the mentioned line. After waiting for about 5 seconds and continuing the execution of the code with F8 it works! It actually gives me my GPS-coordinates!

    It seems like the code is working but needs some time to Launch the GPS-module or whatever in order to give out the coordinates. In the meantime it just gives out that run-time error. If this is the case, why doesn't it work on the second try as the GPS-module should be running, right?

    I'm not an expert in programming but in this case I don't think thats the reason why I'm so confused haha.
    Geolocation.dll is in the Windows\System32 folder

    Glad you got it to work ...after a fashion... I tried the same but it doesn't work for me - just get the same error repeatedly
    I tried bypassing the error and just get 0,0

    Have a look at my Get Current Location app and let me know how that works for you
    Here's an example based on the centre of London

    Click image for larger version. 

Name:	LocationMap.jpg 
Views:	7 
Size:	106.8 KB 
ID:	37949
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-18-2013, 09:06 AM
  2. macro not working in Windows 7 machine
    By vemi007 in forum Programming
    Replies: 2
    Last Post: 04-19-2012, 01:45 AM
  3. Replies: 1
    Last Post: 12-02-2010, 11:08 PM
  4. Replies: 1
    Last Post: 08-17-2010, 11:24 PM
  5. Replies: 10
    Last Post: 05-19-2010, 04:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums