LogIn Form 3rd time lucky

gaccess

Registered User.
Local time
Today, 15:27
Joined
Apr 17, 2011
Messages
32
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)
 
you can send anything to the opened form using it's OpenArgs (form.OpenArgs)

you can also use a public variable to filter the combo
 
oops I got a bit carried away in the cut and paste dept, thought I was seeing double.
Thanks for your help but it was a bit like pushing a blind man from behind into the freeway traffic-he might make the other side
So I have tried
DoCmd.OpenForm "frmIncident", acNormal, OpenArgs:="strDepot" also "DepotID" also "lngID" they all show all records not just the matching ones

DepotID is the foreign key in the main table - tblPasscode is lngID, strDepot, strPasscode. The control in the mainform has DepotId as its Control Source:confused:
 
"strDepot" is a text string
strDepot is the value of the strDepot variable
me.strDepot is the value of the field on the form

so in you case (asumin strDepot is a field on the form) it should be:
DoCmd.OpenForm "frmIncident", acNormal, OpenArgs:=me.strDepot
or
DoCmd.OpenForm "frmIncident", acNormal, , , , , me.strDepot

but this will only send the value to the other form.
what you do with it there it's up to you ;)
 

Users who are viewing this thread

Back
Top Bottom