Results 1 to 8 of 8
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    access 64bit problem i think

    Hi Guys



    I have this code in a module that runs on the form "frmLogin" on load event

    Code:
     
    Option Compare Database
    Option Explicit
    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
        Dim dbs As Object, prp As Variant
        Const conPropNotFoundError = 3270
        Set dbs = CurrentDb
        On Error GoTo Change_Err
        dbs.Properties(strPropName) = varPropValue
        ChangeProperty = True
    Change_Bye:
        Exit Function
    Change_Err:
        If Err = conPropNotFoundError Then                ' Property not found.
            Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
            dbs.Properties.Append prp
            Resume Next
        Else
            ' Unknown error.
            ChangeProperty = False
            Resume Change_Bye
        End If
    
    End Function
    Function BypassKey(onoff As Boolean)
        Const DB_Boolean As Long = 1
        ChangeProperty "AllowBypassKey", DB_Boolean, onoff
    End Function
    when users on 64bit access open the database they get
    "Compile Error: Code in this project must be updated for use on 64bit systems"

    I fear I have hit another massive learning curve lol, I have been looking about the web via Google but to be honest i'm not really understanding how to resolve this
    I think I have to declare PTRSafe but I am totally lost with this

    any help would be wonderful
    many thanks


    Steve

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    You only need PTRSafe for API functions. I don't see any here.
    they would be declared at the top of a module.

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi ranman

    wow that was quick
    many thanks, I will do some digging to find the exact course of the issue,

    many thanks
    Steve

  4. #4
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi

    i'm thinking this is the culprit,
    Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long

    I believe I have to change long to Longlong
    but not sure about the PRTSafe bit

    Steve

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    then it would be like:

    Code:
    #if Win64 then
       Declare PtrSafe Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
    #else
       Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
    #end if

  6. #6
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Mate

    you are a star, many thanks indeed

    Steve

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    Although values may well remain in the 'long' range you should also change the long to longlong so

    #if Win64 then
    Declare PtrSafe Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As LongLong) As LongLong

    Alternatively use LongPtr which will convert according to version of office to Long or LongLong - see this link

    https://msdn.microsoft.com/en-us/lib.../gg251378.aspx

  8. #8
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Ajax

    that's great, will make sure I catch that
    many thanks

    Steve

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

Similar Threads

  1. Replies: 0
    Last Post: 09-10-2016, 11:55 AM
  2. converting code to 64bit
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 03-09-2015, 09:16 AM
  3. Replies: 3
    Last Post: 05-03-2013, 12:57 AM
  4. Replies: 2
    Last Post: 10-26-2012, 01:18 PM
  5. Replies: 1
    Last Post: 04-08-2011, 08:06 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