I've looked at the example dB and see many things that should be fixed (IMHO).
1) The dB should be split into a FE and a BE. Each user should have a COPY of the FE on their computer. Multiple users in one non-split dB, sooner or later, will be corrupted. Not a matter of IF.... just a matter of WHEN.
2) EVERY module should have the TOP two lines of
Code:
Option Compare Database
Option Explicit
3) You should take the time to properly rename objects, not blindly accept what MS names them.
Code:
'------------------------------------------------------------
' Command22_Click
'
'------------------------------------------------------------
Private Sub Command22_Click()
On Error GoTo Command22_Click_Err
DoCmd.Quit acPrompt
Command22_Click_Exit:
Exit Sub
Command22_Click_Err:
MsgBox Error$
Resume Command22_Click_Exit
End Sub
Private Sub Command48_Click()
DoCmd.OpenForm "frmTrainingEmployeeListing", acNormal, "", "[EmployeesID]=" & txtUserID, , acNormal
End Sub
Private Sub Command58_Click()
DoCmd.OpenForm "frmTrainingEmployeeScheduled", acNormal, "", "[EmployeesID]=" & txtUserID, , acNormal
End Sub
Private Sub Command66_Click()
DoCmd.OpenForm "frmTrainingUpcomingClasses"
End Sub
What do these subs do???
How about now???
Code:
Private Sub cmdExit_Click()
On Error GoTo cmdExit_Click_Err
DoCmd.Quit acPrompt
cmdExit_Click_Exit:
Exit Sub
cmdExit_Click_Err:
MsgBox Error$
Resume cmdExit_Click_Exit
End Sub
Private Sub btnTrainingList_Click()
DoCmd.OpenForm "frmTrainingEmployeeListing", acNormal, "", "[EmployeesID]=" & txtUserID, , acNormal
End Sub
Private Sub btnTrainingSched_Click()
DoCmd.OpenForm "frmTrainingEmployeeScheduled", acNormal, "", "[EmployeesID]=" & txtUserID, , acNormal
End Sub
Private Sub btnTrainingClsses_Click()
DoCmd.OpenForm "frmTrainingUpcomingClasses"
End Sub
In the button "Command22_Click", you have
Code:
DoCmd.Quit acPrompt
The "acPrompt" argument is only for CHANGES to the form design. It does NOT prompt to save data.
This is the code I use:
Code:
Private Sub cmdExit_Click()
If MsgBox("Exit Access?", vbYesNo, "Are You Sure?") = vbYes Then
DoCmd.Quit
End If
End Sub
4) In form "frmLogin", I would do as suggested and add a hidden text box to hold the employeeID. If the username and password match, fill in the employee id text box, then hide the form (instead of closing the form).
Code:
Private Sub Command0_Click() '<< RENAME
Dim X As Long
If IsNull(Me.txtUsername) Then
MsgBox "Invalid username"
Exit Sub
End If
If IsNull(Me.txtPassword) Then
MsgBox "Invalid Password"
Exit Sub
End If
X = Nz(DLookup("EmployeesID", "qryEmployeesCurrent", "Username='" & Me.txtUsername & "' AND Password='" & Me.txtPassword & "'"))
If X > 0 Then
' We have a valid user
Me.tbEmpID = x
DoCmd.OpenForm "frmMainMenu"
Forms!frmLogin.Visible = False
' Forms!frmMainMenu!txtUserID = X
' Forms!frmMainMenu!txtUsername = Me.txtUsername
' DoCmd.Close acForm, "frmLogin"
Else
MsgBox "invalid Login"
End If
End Sub
Then you can have the info available for any form.......