Hello,
I have cboUtilizator (User) for choosing username, txtp for password input and a text box called lngEmpID wich Control Source =[cboUtilizator]. The user select his username, enter his password then when he click the OK command button the code verify if the password is correct for selected user, and if it's correct based on lngEmpID, opens a ChangePassword form showing the user data. This way he can change only his password, 'cause this is the only information he can access.
The problem is: If I put this code
to a command button, it's OK. But if I insert it in the code, the way showed bellow, it isn't working anymore, on the line
it give me the following error message:
"Run-time error '2467'
The expression you entered referes to an object that is closed or doesn't exist."
Can anybody help me to fix this?
Thanx,
Attila
I have cboUtilizator (User) for choosing username, txtp for password input and a text box called lngEmpID wich Control Source =[cboUtilizator]. The user select his username, enter his password then when he click the OK command button the code verify if the password is correct for selected user, and if it's correct based on lngEmpID, opens a ChangePassword form showing the user data. This way he can change only his password, 'cause this is the only information he can access.
The problem is: If I put this code
Code:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "ChangePass"
stLinkCriteria = "[lngEmpID]=" & Me![lngEmpID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
to a command button, it's OK. But if I insert it in the code, the way showed bellow, it isn't working anymore, on the line
Code:
stLinkCriteria = "[lngEmpID]=" & Me![lngEmpID]
"Run-time error '2467'
The expression you entered referes to an object that is closed or doesn't exist."
Can anybody help me to fix this?
Thanx,
Attila
Code:
Private Sub Command5_Click()
'Check to see if data is entered into the UserName (cboUtilizator) combo box
If IsNull(Me.cboUtilizator) Or Me.cboUtilizator = "" Then
MsgBox "Va rugam introduceti numele de utilizator.", vbOKOnly, "Completare obligatorie"
Me.cboUtilizator.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box (txtp)
If IsNull(Me.txtp) Or Me.txtp = "" Then
MsgBox "Va rugam introduceti parola.", vbOKOnly, "Completare obligatorie"
Me.txtp.SetFocus
Exit Sub
End If
'Check value of password in table users (Utilizatori) to see if this matches value chosen in combo box
If Me.txtp.Value = DLookup("Parola", "Utilizatori", "[lngEmpID]=" & Me.cboUtilizator.Value) Then
If DLookup("TipUtilizator", "Utilizatori", "[lngEmpID]=" & Me.cboUtilizator.Value) = "Admin" Then
lngMyEmpID = Me.cboUtilizator.Value
DoCmd.Close acForm, "LogareConsolaUser", acSaveNo
DoCmd.Close acForm, "Meniu", acSaveNo
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "ChangePass"
stLinkCriteria = "[lngEmpID]=" & Me![lngEmpID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
Dim stDocName4 As String
Dim stLinkCriteria1 As String
stDocName4 = "ErrLog"
DoCmd.OpenForm stDocName4, , , stLinkCriteria1
Me.txtp.SetFocus
End If
End If
End Sub