Auto Open Form on Startup with condition
Posted on 2010-11-30
I have a form that automatically opens on startup of the program.
For security purposes, I need to check the userID of the person logged in, to allow them access into the program or not. I have put this code in on the "Open" Event. I get the MsgBox for unauthorized users, however, the form still opens (I guess because it set that way in the Startup box.) Any other ideas on how to do this?
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_RunReports_Click
If DLookup("OfficeLocation", "tblAuditor", "ChubbID='" & GetUserCredentials(2) & "'") = 1 Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Splash"
DoCmd.OpenForm stDocName, , , stLinkCriteria
MsgBox "You are not authorized to view this form"