Results 1 to 7 of 7
  1. #1
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126

    Installing 64-bit Access give conpile errors ??

    I have installed the 64-bit version of Access and I now get some compile-errors in my simple password module !
    The module worked nicely for years in the 32-bit version and I'm not able to see whats wrong !



    I get "Type mismatch" in the marked <<<<<<<<<<<<<<<< line - here is my code:

    Code:
    Option Compare Database
    Option Explicit
     
    Private hHook As Long
     
    Public Function NewProc(ByVal lngCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim RetVal
        Dim strClassName As String, lngBuffer As Long
        If lngCode < HC_ACTION Then
            NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)
            Exit Function
        End If
        strClassName = String$(256, " ")
        lngBuffer = 255
        If lngCode = HCBT_ACTIVATE Then    'A window has been activated
            RetVal = GetClassName(wParam, strClassName, lngBuffer)
            If Left$(strClassName, RetVal) = "#32770" Then  'Class name of the Inputbox
                'This changes the edit control so that it display the password character *.
                'You can change the Asc("*") as you please.
                SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), &H0
            End If
        End If
        'This line will ensure that any other hooks that may be in place are
        'called correctly.
        CallNextHookEx hHook, lngCode, wParam, lParam
    End Function
     
    Public Function InputBoxPW(Prompt, Optional Title, Optional Default, Optional XPos, _
                            Optional Ypos, Optional HelpFile, Optional Context) As String
        Dim lngModHwnd As Long, lngThreadID As Long
        lngThreadID = GetCurrentThreadId
        lngModHwnd = GetModuleHandle(vbNullString)
        hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)    <<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE "AddressOf NewProc" is marked for compile error Type mismatch !!!!!!!!
        InputBoxPW = InputBox(Prompt, Title, Default, XPos, Ypos, HelpFile, Context)
        UnhookWindowsHookEx hHook
    End Function
    
    Public Sub updatePrivat(frm As Form)
        ' Ved fortløbende fomularer skal i stedte anvendes
        ' betinget formattering
        frm.Controls("Sti_til_fil").Visible = Not frm.Controls("chbPrivat")
        frm.Controls("btnOpen").Visible = frm.Controls("chbPrivat")
    End Sub
    
    Public Function getAdgangskode() As Boolean
        Dim kode As String
        kode = InputBoxPW("se de private oplysninger (" & Time & "): ", "Angiv adgangskode for at ...")
        ' her kan evt. kodes en ANDEN ide mht. adgangskoden
        getAdgangskode = (kode = Mid(Time, 5, 1) & Mid(Time, 7, 1))
    End Function
    
    Public Sub chbPrivatClick(frm As Form)
        If frm.Controls("chbPrivat").OldValue = True Then
            If getAdgangskode Then
            Else
                frm.Controls("chbPrivat").Value = frm.Controls("chbPrivat").OldValue
            End If
        Else
            If Veto("PAS PÅ !" & vbCrLf & _
                    "Du skal kunne adgangskoden, hvis du" & vbCrLf & _
                    "senere vil se oplysningerne igen !" & CrLf(2) & _
                    "Vil du fortsat gøre oplysningerne 'private' ?", vbDefaultButton2) = vbNo Then
                frm.Undo
            Else
            End If
        End If
    End Sub
    I know it's NOT a bullit proof password method, but it works for me

    Please, tell me what's wrong !

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    This function/API will likely need changing to 64 bit? SetWindowsHookEx

    Possibly need PtrSafe and LongPtr

    Start Googling.
    https://isladogs.co.uk/32-64-bit-conversion/index.html
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    On a quick glance, this appears to be an over complicated way of viewing passwords

    Anyway, you will either need to replace the code with something else or update all APIs for 64-bit together with other related Type statements & variables where appropriate.
    Unfortunately you omitted the API declarations from your code
    To get you started, these are the 64-bit versions of SetWindowsHookEx, CallNextHookEx and UnhookWindowsHookEx

    Code:
    Declare PtrSafe Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" _
        (ByVal idHook As Long, ByVal lpfn As LongPtr, ByVal hmod As LongPtr, ByVal dwThreadId As Long) As LongPtr
    
    Declare PtrSafe Function CallNextHookEx Lib "user32" _
        (ByVal hHook As LongPtr, ByVal ncode As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
    
    Declare PtrSafe Function UnhookWindowsHookEx Lib "user32" (ByVal hhk As LongPtr) As Long
    There may well be others that I didn't notice
    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

  4. #4
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    #isladogs
    I know it's a mess ... but it's working - WAS working until this 32-bit to 64-bit update.

    I think I'll have to read some of you very nice articles out there - THX for yor time !

  5. #5
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    I managed to get it working again - but it's still a mess

    But I have myself to blame - THX for your time !

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Glad you got it working but what exactly is the purpose?
    If (as I suspect) you have a masked input box based on code originally written by Daniel Klann back in 2003, then see my article: Masked Input Box (isladogs.co.uk) where I had already converted the code to be 64-bit compatible

    Or if you want to temporarily show a masked password already entered in a textbox then you can use something like this on the mousedown/mouseup events of a button:

    Code:
    Private Sub cmdShow_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)    Me.txtPassword.InputMask = ""
    End Sub
    
    
    Private Sub cmdShow_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
       Me.txtPassword.InputMask = "Password"
    
    End Sub
    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

  7. #7
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    THX - I'll do the cleaning when I'm not so buzy as I am right now !

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

Similar Threads

  1. Installing Access
    By Dan Lee in forum Access
    Replies: 8
    Last Post: 03-20-2017, 07:51 PM
  2. ODBC access (2007) drivers not installing?
    By pandorazboxx in forum Access
    Replies: 0
    Last Post: 09-11-2012, 10:39 AM
  3. Replies: 1
    Last Post: 09-29-2011, 09:39 AM
  4. Access starts installing
    By arunkumar213 in forum Access
    Replies: 0
    Last Post: 06-15-2011, 03:53 AM
  5. Replies: 3
    Last Post: 06-07-2011, 11:02 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