rtdc
Registered User.
- Local time
- Today, 18:52
- Joined
- Feb 27, 2007
- Messages
- 55
I found this great piece of code by Karma in the forum and tested it great, all worked first time. I modified it to show the pc user logon automatically and this then looks up the users name from a lookup table, the user enters their windows password and if it is correct they can enter if not they have three goes and out they go. The trouble is the lookup for the password is unreliable, it will work half a dozen times without problem then it doesn’t any more. The code in question is:
' Now validate the password
rv = LogonUser(usrName, vbNullString, Password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, hToken)
'MsgBox rv
If rv <> 0 Then
' Password validated successfully
DoCmd.OpenForm "TRIGAS Significant Fault Log", acNormal
Me.Visible = False
Else
' Username and password failed validation
MsgBox "Your Password is Invalid"
Me.TXT_PASSWORD.Value = Null
Me.TXT_PASSWORD.SetFocus
If IsNull(Me.count_field) Then
Me.count_field = 1
Else
Me.count_field = Me.count_field + 1
End If
End If
Has anyone had this problem?
Does anyone know if there is a time out of the number of times you can lookup the password?
Is there and easier way of doing this?
I am using Access 2002, cheers.

' Now validate the password
rv = LogonUser(usrName, vbNullString, Password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, hToken)
'MsgBox rv
If rv <> 0 Then
' Password validated successfully
DoCmd.OpenForm "TRIGAS Significant Fault Log", acNormal
Me.Visible = False
Else
' Username and password failed validation
MsgBox "Your Password is Invalid"
Me.TXT_PASSWORD.Value = Null
Me.TXT_PASSWORD.SetFocus
If IsNull(Me.count_field) Then
Me.count_field = 1
Else
Me.count_field = Me.count_field + 1
End If
End If
Has anyone had this problem?
Does anyone know if there is a time out of the number of times you can lookup the password?
Is there and easier way of doing this?
I am using Access 2002, cheers.