I never use the Switchboard wizard nor macro coding. Most experienced programmers avoid both. There is a reason MS has deprecated that form structure.
The following is code I would use and I would not use Switchboard wizard to set up my 'main menu' form. I would use VBA behind buttons. I have not looked at the macro code to see how it might impact this process.
Code behind Login form.
Code:
Private Sub Command1_Click()
Dim strUser As String
If IsNull(Me.txtLogin_ID) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID Required"
Me.txtLogin_ID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter password", vbInformation, "Password Required"
Me.txtPassword.SetFocus
Else
'process the job
strUser = Nz(DLookup("[User Login]", "Security Level", "[User Login] ='" & Me.txtLogin_ID.Value & "' And Password = '" & Me.txtPassword.Value & "'"), "")
DoCmd.Close
If strUser = "" Then
MsgBox "Incorrect Login ID or Password"
Else
'MsgBox "Login ID and Password correct:"
DoCmd.OpenForm "Switchboard", , , , , , strUser
End If
End If
End Sub
Create a textbox on Switchboard named tbxUser - can be not visible. Then code behind Switchboard.
Code:
Private Sub Form_Load()
Me.tbxUser = Me.OpenArgs
End Sub
Code behind Client Details.
Code:
Private Sub Form_Load()
If Forms!Switchboard.tbxUser = "user" Then
Me.AllowAdditions = True
Me.AllowEdits = False
Me.AllowDeletions = False
End If
End Sub
All code modules should have the following two lines in header.
Option Compare Database
Option Explicit
To force the Option Explicit as default, in the VBE window > Tools > Options > check Require Variable Declaration.