after abandoning hope for a day I have seached and found this code on databasedev.co.uk/login
OK it works fine but I still want to filter form to show only the combo box/strDepot field selected.
So I need to add something to the end of the DoCmd.Open Form Lines but i've tried a few things with no joy still. eg DoCmd.OpenForm "frmIncident", , , "Depot = '" & Me.cboUserList & "'" this is working on the current DB but Depot is afield on the main table so updating users/passwords is a real chore
so this is it
Private Sub cmdDepotLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboUserList) Or Me.cboUserList = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboUserList.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassCode) Or Me.txtPassCode = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassCode.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassCode.Value = DLookup("strPasscode", "tblPasscode", _
"[lngID]=" & Me.cboUserList.Value) Then
lngMyID = Me.cboUserList.Value
'Close logon form and open splash screen
DoCmd.OpenForm "frmIncident"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassCode.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassCode) Or Me.txtPassCode = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassCode.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassCode.Value = DLookup("strPasscode", "tblPasscode", _
"[lngID]=" & Me.cboUserList.Value) Then
lngMyID = Me.cboUserList.Value
'Close logon form and open splash screen
DoCmd.OpenForm "frmIncident"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassCode.SetFocus
End If
'If User Enters incorrect password 3 times
'database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
oh and i have removed a close login form line until i get this sorted.
I'm sure the solution must be simple (bit like me really)
OK it works fine but I still want to filter form to show only the combo box/strDepot field selected.
So I need to add something to the end of the DoCmd.Open Form Lines but i've tried a few things with no joy still. eg DoCmd.OpenForm "frmIncident", , , "Depot = '" & Me.cboUserList & "'" this is working on the current DB but Depot is afield on the main table so updating users/passwords is a real chore
so this is it
Private Sub cmdDepotLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboUserList) Or Me.cboUserList = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboUserList.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassCode) Or Me.txtPassCode = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassCode.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassCode.Value = DLookup("strPasscode", "tblPasscode", _
"[lngID]=" & Me.cboUserList.Value) Then
lngMyID = Me.cboUserList.Value
'Close logon form and open splash screen
DoCmd.OpenForm "frmIncident"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassCode.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassCode) Or Me.txtPassCode = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassCode.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassCode.Value = DLookup("strPasscode", "tblPasscode", _
"[lngID]=" & Me.cboUserList.Value) Then
lngMyID = Me.cboUserList.Value
'Close logon form and open splash screen
DoCmd.OpenForm "frmIncident"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassCode.SetFocus
End If
'If User Enters incorrect password 3 times
'database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
oh and i have removed a close login form line until i get this sorted.
I'm sure the solution must be simple (bit like me really)