Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    32 bit database will not open with 64 bit version of Access

    I testing several databases that were built with the 32bit of Access on machines that are using the 64 bit of Access and am getting a couple different errors.

    For this one the database won't open under any circumstances
    Click image for larger version. 

Name:	FIMS 64 BIT Error.PNG 
Views:	40 
Size:	6.6 KB 
ID:	40663

    This one opened, but the start up form won't display. I was able to get to the form and open it manually. When I did I received this error. By commenting the code in red the form opened normally, but I am unsure what this code does
    Click image for larger version. 

Name:	pairs 64 bit error (2).PNG 
Views:	45 
Size:	26.2 KB 
ID:	40664

    I also found these two sub that call the above functions.
    Click image for larger version. 

Name:	pairs 64 bit error (2).PNG 
Views:	43 
Size:	19.7 KB 
ID:	40665

    Your thoughts on either or both of these would be appreciated.



    Thanks,

    Paul

  2. #2
    Mickjav is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Location
    Margate, Kent
    Posts
    123
    Database will only work in the version they are complied In
    And you need to update you API Calls to use PtrSafe and LongPtr
    http://allapi.mentalis.org/apilist/apilist.php
    https://www.utteraccess.com/wiki/Category:API

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Also, in my experience an accdb created by 32bit Access will open fine in 64bit. An accde created by 32bit Access will not, and you get the first error. I've opened numerous 32bit accdb's in 64bit; you have to in order to convert them.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by pbaldy View Post
    Also, in my experience an accdb created by 32bit Access will open fine in 64bit. An accde created by 32bit Access will not, and you get the first error. I've opened numerous 32bit accdb's in 64bit; you have to in order to convert them.
    I have some accdbs that have opened up without errors. So far two others haven't. I've taken one and imported all the objects into a 64 bit Access database, but Function declarations still produce this error. This is occurring in both dbs but I am unfamiliar with this code and not sure how to update it.

    Click image for larger version. 

Name:	code  must be updated.PNG 
Views:	36 
Size:	32.0 KB 
ID:	40669

    Here are the instances where that happens. If I can get through these I might be in the clear.

    Code:
    Declare Function GetSystemMetrics32 Lib "User32" _
        Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
    Code:
    Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
    Code:
    Declare Function SetWindowLong Lib "user64" Alias "SetWindowLongA" _
        (ByVal hwnd As Long, _
        ByVal nIndex As Long, _
        ByVal dwNewLong As Long) As Long
    Code:
    Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
        (ByVal lpPrevWndFunc As Long, _
         ByVal hwnd As Long, _
         ByVal msg As Long, _
         ByVal wParam As Long, _
         ByVal lParam As Long) As Long

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Mickjav covered that in post 2. In simplest terms

    Declare Function...

    becomes

    Declare PtrSafe Function...

    But it can get more complicated, so review the links posted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I did a google search and found a template I could use. I tried using my old code in the else section, but it still kicked out the same error. At this point it is running on both the 32 bit and 64 bit versions of Access, which I didn't expect. I've got one other database to debug. I expect this to work there too.

    Thanks for helping out.

    Paul

    Code:
    #If VBA7 Then
        Declare PtrSafe Function SetWindowLong Lib "user64" Alias "SetWindowLongA" _
        (ByVal hwnd As LongPtr, _
        ByVal nIndex As LongPtr, _
        ByVal dwNewLong As LongPtr) As LongPtr
    
    
    #Else
    
    
     '   Private Declare Sub Sleep Lib "kernel32" (ByVal ms as Long)
    #End If
    Code:
    #If VBA7 Then
    
    
    Public Declare PtrSafe Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
        (ByVal lpPrevWndFunc As LongPtr, _
         ByVal hwnd As LongPtr, _
         ByVal msg As LongPtr, _
         ByVal wParam As LongPtr, _
         ByVal lParam As LongPtr) As LongPtr
    
    #Else
    
    'The old code would not work here
    #End If

  7. #7
    Mickjav is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Location
    Margate, Kent
    Posts
    123
    nIndex
    msg
    dwNewLong
    As LongPtr

    Think these should all be longs

  8. #8
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I'm not surprised, but there is more to this. While the application runs normally, I can no longer compile it. I am getting type mismatch errors on this line of code.

    Code:
    Public Function UpDateRptRecPgmOR(RptRec As ADODB.Recordset, Qtr, provider_ID, Nclient) As Boolean
    Dim i As Integer
            
        RptRec.MoveFirst
        For i = 1 To RptRec.RecordCount - 1
          If RptRec("Quarter") = Qtr And RptRec("Provider_Id") = CInt(provider_ID) Then
              Exit For
          Else
              RptRec.MoveNext
          End If
        Next i
        
         RptRec("Program_ORs") = Nclient
         RptRec.Update
         
        End Function
    This happens on two other functions. There are no longs in these functions. I checked the links, but didn't see anything related. I altered this line of code till the code compiled, but I need a real solution.

    From this

    Code:
        For i = 1 To RptRec.RecordCount - 1 
    '

    to

    Code:
    For i = 1 To 2 'RptRec.RecordCount - 1

  9. #9
    Mickjav is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Location
    Margate, Kent
    Posts
    123
    Your gettng the errors as your not using LongPtr correctly read up up 64 bit api calls

  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
    Rather than react to each error without a clear understanding of API conversions, I suggest you research the correct approach
    The following should help
    1. Read the article by Phillip Stiefel at https://codekabinett.com/rdumps.php?...ion-vba-64-bit
    2. download the Windows API Viewer by Ron de Bruin from https://www.rondebruin.nl/win/dennis...sapiviewer.htm
    That includes both 32-bit and 64-bit versions of most APIs.

    As well as adding PtrSafe for all 64-bit declarations you must convert pointers/handles such as hWnd to LongPtr.
    Don't forget to review those in Type code blocks
    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
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I did some research and fixed my declarations on my own. While I did not see any other Longs in the code, after some experimentation I changed the Integer data type to LongPtr and solved the problem.

    I still don't know what an API is, but I guess it doesn't matter.

  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 Paul H View Post
    I did some research and fixed my declarations on my own. While I did not see any other Longs in the code, after some experimentation I changed the Integer data type to LongPtr and solved the problem.

    I still don't know what an API is, but I guess it doesn't matter.
    I've no idea which API contains the Integer datatype you are talking about but converting that to LongPtr is completely wrong.
    As I said before, if you are going to convert databases to 64-bit, you need to do it properly
    Even if you've now managed to compile your database(s), it doesn't mean the APIs will now work correctly
    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

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Bing "API definition".

    Application Programming Interface

    "In the simplest terms, APIs are sets of requirements that govern how one application can talk to another. APIs aren’t at all new; whenever you use a desktop or laptop, APIs are what make it possible to move information between programs—for instance, by cutting and pasting a snippet of a LibreOffice document into an Excel spreadsheet."

    The API code referenced in this thread is for Windows/Access interaction.


    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by isladogs View Post
    I've no idea which API contains the Integer datatype you are talking about but converting that to LongPtr is completely wrong.
    As I said before, if you are going to convert databases to 64-bit, you need to do it properly
    Even if you've now managed to compile your database(s), it doesn't mean the APIs will now work correctly
    I'm not sure this is related to an API, but this is what prevented the db from compiling. The error I received was Datatype Mismatch.

    Code:
    Public Function UpDateRptRecPgmOR(RptRec As ADODB.Recordset, Qtr, provider_ID, Nclient) As Boolean
    
    Dim i As Integer
            
        RptRec.MoveFirst
        For i = 1 To RptRec.RecordCount - 1
          If RptRec("Quarter") = Qtr And RptRec("Provider_Id") = CInt(provider_ID) Then
              Exit For
          Else
              RptRec.MoveNext
          End If
        Next i
        
         RptRec("Program_ORs") = Nclient
         RptRec.Update
         
        End Function
    Code:
    Public Function UpDateRptRecPgmOR(RptRec As ADODB.Recordset, Qtr, provider_ID, Nclient) As Boolean
    
    Dim i As LongPtr
            
        RptRec.MoveFirst
        For i = 1 To RptRec.RecordCount - 1
          If RptRec("Quarter") = Qtr And RptRec("Provider_Id") = CInt(provider_ID) Then
              Exit For
          Else
              RptRec.MoveNext
          End If
        Next i
    
         RptRec("Program_ORs") = Nclient
         RptRec.Update
         
        End Function
    I'm not receiving any errors in the application. It's compiled and converted to an ACCDE and working normally. I'm not sure there is anything left to fix.

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Nothing to do with an API.

    Integer is fine for record count providing the count doesn't exceed integer limit (32767 IIRC).
    I normally use Long for that reason. LongPtr is incorrect even if it compiled

    If I starts at 1. and ends with RecCount -1, the final record will be excluded
    Normally start at zero or remove the final -1.
    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

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 02-05-2018, 08:14 PM
  2. Replies: 2
    Last Post: 02-01-2018, 08:39 AM
  3. Open older version of database
    By NISMOJim in forum Access
    Replies: 3
    Last Post: 05-30-2015, 03:23 PM
  4. Replies: 2
    Last Post: 04-17-2013, 08:53 PM
  5. Replies: 2
    Last Post: 03-14-2013, 04:43 AM

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