Hi everyone
So i'm working on creating a classic login form. The VBA I wrote did initially work but now suddenly I get this error The OpenForm action was canceled I don't know what happened but if someone could have a look at my VBA and maybe offer some guidance, that would be appreciated. Thank you!
Private Sub btnLogin_Click()
Dim RecSet As Recordset
Set RecSet = CurrentDb.OpenRecordset("tblEmployees", dbOpenSnapshot, dbReadOnly)
RecSet.FindFirst "userName='" & Me.txtUserName & "'"
If RecSet.NoMatch = True Then
Me.lblInvalidUserName.Visible = True
Me.txtUserName.SetFocus
Exit Sub
End If
Me.lblInvalidUserName.Visible = False
If RecSet!Password <> Nz(Me.txtPassWord, """") Then
Me.lblInvalidPassword.Visible = True
Me.txtPassWord.SetFocus
Exit Sub
End If
Me.lblInvalidPassword.Visible = False
DoCmd.OpenForm "frmMain"
DoCmd.Close acForm, Me.Name
End Sub
DoCmd.OpenForm "frmMain"is highlighted yellow and seems to be the problem but I'm confused because it was working previously
So i'm working on creating a classic login form. The VBA I wrote did initially work but now suddenly I get this error The OpenForm action was canceled I don't know what happened but if someone could have a look at my VBA and maybe offer some guidance, that would be appreciated. Thank you!
Private Sub btnLogin_Click()
Dim RecSet As Recordset
Set RecSet = CurrentDb.OpenRecordset("tblEmployees", dbOpenSnapshot, dbReadOnly)
RecSet.FindFirst "userName='" & Me.txtUserName & "'"
If RecSet.NoMatch = True Then
Me.lblInvalidUserName.Visible = True
Me.txtUserName.SetFocus
Exit Sub
End If
Me.lblInvalidUserName.Visible = False
If RecSet!Password <> Nz(Me.txtPassWord, """") Then
Me.lblInvalidPassword.Visible = True
Me.txtPassWord.SetFocus
Exit Sub
End If
Me.lblInvalidPassword.Visible = False
DoCmd.OpenForm "frmMain"
DoCmd.Close acForm, Me.Name
End Sub
DoCmd.OpenForm "frmMain"is highlighted yellow and seems to be the problem but I'm confused because it was working previously
Last edited: