T
Tom
Below is a function that I found in a sample application. This function
works well and checks the validity of correct passwords.
Now, I need some help with modifying it... currently, when a user enters a
"Division" and "Branch" plus correct password the line "MsgBox "Login
Successful...Proceed to subform!", vbInformation + vbOKOnly, "Information""
is executed and shows appropriate message box.
I now want to bring up a query that shows all records based on the
"Division" and "Branch" selection. Currently, there are 126 records in
tblKPIAnswers... each Division/Branch combination has 21 testing records.
Please refer to a sample file (Password.zip) at:
http://tombock2004.i8.com/Test/
So, my goal is the following:
1. Open frmLogin
2. Select any of the 6 combinations (e.g. if "Division" = "California", then
Branch = "Los Angeles" or "San Francisco")
3. Click "Login" (enter "test" as the password... it's the same for all 6
combinations)
4. Now, depending on the selected Division/Branch combination, I should see
only 21 records in "qryTest" (either, those of LA or San Francisco... based
on what I chose for the Branch).
How do I make that modification (between '&&&&&&&&&&&&&&&&&) ???
Thanks,
Tom
****************************
Private Sub cmdLogin_Click()
If Nz(Me.cboDivision, "") = "" Then
MsgBox "You must select a division!", vbExclamation + vbOKOnly,
"Error"
ElseIf Nz(Me.cboBranch, "") = "" Then
MsgBox "You must select a branch!", vbExclamation + vbOKOnly,
"Error"
ElseIf Nz(Me.txtPassword, "") = "" Then
MsgBox "You must enter a password!", vbExclamation + vbOKOnly,
"Error"
Else
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT * FROM tblOrganisationAndCredentials " & _
"WHERE [Division] = '" & Me.cboDivision & "' " & _
"AND [Branch] = '" & Me.cboBranch & "' " & _
"AND [Password] = '" & Me.txtPassword & "'"
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
If rst.EOF Then 'NO RECORDS
MsgBox "Invalid password! Please retry.", vbInformation +
vbOKOnly, "Information"
Else 'A MATCHING RECORD WAS FOUND
MsgBox "Login Successful...Proceed to subform!", vbInformation +
vbOKOnly, "Information"
'&&&&&&&&&&&&&&&&&
'I need some code here that pulls proper record set (in qryTest)
based on Division/Branch selection
'&&&&&&&&&&&&&&&&&
End If
End If
End Sub
****************************
works well and checks the validity of correct passwords.
Now, I need some help with modifying it... currently, when a user enters a
"Division" and "Branch" plus correct password the line "MsgBox "Login
Successful...Proceed to subform!", vbInformation + vbOKOnly, "Information""
is executed and shows appropriate message box.
I now want to bring up a query that shows all records based on the
"Division" and "Branch" selection. Currently, there are 126 records in
tblKPIAnswers... each Division/Branch combination has 21 testing records.
Please refer to a sample file (Password.zip) at:
http://tombock2004.i8.com/Test/
So, my goal is the following:
1. Open frmLogin
2. Select any of the 6 combinations (e.g. if "Division" = "California", then
Branch = "Los Angeles" or "San Francisco")
3. Click "Login" (enter "test" as the password... it's the same for all 6
combinations)
4. Now, depending on the selected Division/Branch combination, I should see
only 21 records in "qryTest" (either, those of LA or San Francisco... based
on what I chose for the Branch).
How do I make that modification (between '&&&&&&&&&&&&&&&&&) ???
Thanks,
Tom
****************************
Private Sub cmdLogin_Click()
If Nz(Me.cboDivision, "") = "" Then
MsgBox "You must select a division!", vbExclamation + vbOKOnly,
"Error"
ElseIf Nz(Me.cboBranch, "") = "" Then
MsgBox "You must select a branch!", vbExclamation + vbOKOnly,
"Error"
ElseIf Nz(Me.txtPassword, "") = "" Then
MsgBox "You must enter a password!", vbExclamation + vbOKOnly,
"Error"
Else
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT * FROM tblOrganisationAndCredentials " & _
"WHERE [Division] = '" & Me.cboDivision & "' " & _
"AND [Branch] = '" & Me.cboBranch & "' " & _
"AND [Password] = '" & Me.txtPassword & "'"
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
If rst.EOF Then 'NO RECORDS
MsgBox "Invalid password! Please retry.", vbInformation +
vbOKOnly, "Information"
Else 'A MATCHING RECORD WAS FOUND
MsgBox "Login Successful...Proceed to subform!", vbInformation +
vbOKOnly, "Information"
'&&&&&&&&&&&&&&&&&
'I need some code here that pulls proper record set (in qryTest)
based on Division/Branch selection
'&&&&&&&&&&&&&&&&&
End If
End If
End Sub
****************************