I am trying to create a database that has a login form for users. I found some code that seems like it should work, but it's not working completely. The code is shown below. Everything seems to work except opening the password change form. The only things on the login form are a combobox that contains the names of the users and an unbound textbox for the users to enter their password. The combobox row source is the folllowing:
I would like the combobox to only show the Fullname column, but it is showing the Password column as well.
The code that I put into the AfterUpdate Event of the unbound textbox is below.
Any help would be appreciated. I'm not well versed in VBA, which is why I am using someone else's code here. I am thinking the PWReset column is Column 3, not 4. However, it still isn't working when I change that to a 3. I think maybe I'm not understanding how it's set up. I put the PWReset in the table as a Yes/No field. I'm not sure if that's what it is supposed to be.
Thank you for your time.
Code:
SELECT tblUser.UserID, [Lname] & ", " & [FName] AS Fullname, tblUser.Password, tblUser.PWReset, tblUser.AccessLevelID FROM tblUser ORDER BY tblUser.LName, tblUser.FName;
I would like the combobox to only show the Fullname column, but it is showing the Password column as well.
The code that I put into the AfterUpdate Event of the unbound textbox is below.
Code:
Private Sub txtPassword_AfterUpdate()
'Check that User is selected
If IsNull(Me.cboUser) Then
MsgBox "You need to select a user!", vbCritical
Me.cboUser.SetFocus
Else
'Check for correct password
If Me.txtPassword = Me.cboUser.Column(2) Then
'Check if password needs to be reset
If Me.cboUser.Column(4) Then
DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser
End If
DoCmd.OpenForm "frmMainMenu"
Me.Visible = False
Else
MsgBox "Password does not match, please re-enter!", vboOkOnly
Me.txtPassword = Null
Me.txtPassword.SetFocus
End If
End If
End Sub
Any help would be appreciated. I'm not well versed in VBA, which is why I am using someone else's code here. I am thinking the PWReset column is Column 3, not 4. However, it still isn't working when I change that to a 3. I think maybe I'm not understanding how it's set up. I put the PWReset in the table as a Yes/No field. I'm not sure if that's what it is supposed to be.
Thank you for your time.