Hi guys,
I have this code for password change on a form, but cannot get it to work, keeps asking value for intUserID on execution, where as I already have assigned in green highlight , cboEmployee is a unbound filed on the form
WHere am I going wrong?
intUserID = Me.cboEmployee
strOldPassword = DLookup("[strEmpPassword]", "tblEmployees", "[lngEmpID]=" & intUserID)
I have this code for password change on a form, but cannot get it to work, keeps asking value for intUserID on execution, where as I already have assigned in green highlight , cboEmployee is a unbound filed on the form
WHere am I going wrong?
Code:
Private Sub Command147_Click()
Dim intUserID As Integer
Dim strOldPassword As String
'Check to see if data is entered into the password box
If IsNull(Me.TxtCurrent) Or Me.TxtCurrent = "" Then
MsgBox "You must enter your current password", vbOKOnly, "Required Data"
Me.TxtCurrent.SetFocus
Exit Sub
End If
If Me.txtNew <> Me.TxtNew2 Then
MsgBox "You must enter your new password correctly in fields", vbOKOnly, "Required Data"
Me.txtNew.SetFocus
Exit Sub
End If
intUserID = Me.cboEmployee
strOldPassword = DLookup("[strEmpPassword]", "tblEmployees", "[lngEmpID]=" & intUserID)
Code:
Select Case strOldPassword
Case Is = Me.TxtCurrent
UserID = Me.cboEmployee
Me.txtNew.SetFocus
Dim strSQL As String
strSQL = "UPDATE tblEmployees SET strEmpPassword = '" & Me.txtNew.Text & "' WHERE lngEmpID = intUserID"
DoCmd.RunSQL strSQL
Last edited by a moderator: