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 !