I'm sure this has been hashed out many times, but I cannot figure out a solution that works for my DB. I am seriously new to coding VBA and have implemented the security features found in this tutorial: http://www.accesssecurityblog.com/po...ccess-VBA.aspx.
I have disabled the Navigation Pane, Ribbon, etc. so that way the database is only able to be edited by holding Shift and opening the DB.
The problem only exists when I open the DB like a user would.
The problem comes when I try to exit the DB with the frmMainMenu still open. If I close this form (via a command button) prior to closing the DB I don't get the 2450 error. If I close the DB while the frmMainMenu is still open I get the 2450 error.
The error states that:
The above guide had me hide frmLogin, but not close it, so as to maintain the user-level security to be referenced by VBA code in other forms.Code:"[The DB] cannot find the referenced form 'frmLogin'.
This is the code that was used in frmLogin to manage the security:
The code in red is where I hide the form.Code:Private Sub txtPassword_AfterUpdate() 'Check that a user is selected If IsNull(Me.cboUser) Then 'If no user is selected, display message box MsgBox "Please select a user before entering a password.", vbCritical 'Move cursor into USER field 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(3) = True Then DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser End If 'Open MAIN MENU if PASSWORD is correct DoCmd.OpenForm "frmMainMenu" 'Hide LOGIN form Me.Visible = False Else 'Upon incorrect password, display message box MsgBox "Incorrect password. Please try again.", vbCritical 'Empty PASSWORD field for re-entry Me.txtPassword = Null 'Move cursor to the PASSWORD field Me.txtPassword.SetFocus End If End If End Sub
I don't know what the problem is since the form is still technically open (just hidden). I have tried a couple of different approaches to solving this, but none have been successful.
I would love a solution where I don't have to remove the application close button (big 'X'). That is a lot more coding than I would like to do.
Thanks for any help you guys are able to provide!