Hi all,
I was wondering if any of you could see what is wrong with this code? The line DoCmd.OpenForm "frmOutstandingReviews" is being hit but it isn't opening the form. Is it because I open another form directly afterwards?
What I'm aiming for is if someone still has work to do the form pops up to tell them before the main dashboard opens, but it just won't open.
Hope that's clear, I don't get any error message, just nothing happens
Code:
Private Sub cmdLogin_Click()
Dim DashboardPic As String
Dim rs As DAO.Recordset
'Check that both a username and password have been added
If IsNull(Me.txtPassword) Or IsNull(Me.cboUserName) Then
MsgBox "You must enter both a username and password", vbOKOnly, "Missing Data"
Exit Sub
End If
'Check the User's Password matches that in the users table
If Me.txtPassword.Value <> DLookup("Password", "tblUsers", _
"[ID]=" & Me.cboUserName.Value) Then
' Inform the user of an incorrect password and close
MsgBox "Password Invalid. Please try again", vbOKOnly, "Invalid Entry"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check whether the user has any outstanding IPS plans or procedures to review
' If so, pop up the outstanding reviews form.
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblIPScomments WHERE [MainReviewer]=" & Me.cboUserName)
If Not (rs.BOF And rs.EOF) Then
DoCmd.OpenForm "frmOutstandingReviews"
Else
' No outstanding IPS plans but there may be outstanding procedures so check this
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblProcComments WHERE [PrimaryReviewer]=" & Me.cboUserName)
If Not (rs.BOF And rs.EOF) Then
DoCmd.OpenForm "frmOutstandingReviews"
End If
End If
rs.Close
Set rs = Nothing
' Open frmDashboard The On Open even of frmDashboard takes the userID from
' This form and saves it for furture reference on frmDashboard
DoCmd.OpenForm "frmDashboard"
' Close this form
DoCmd.Close acForm, "frmLogin", acSaveNo
End Sub