I have a login form where sales reps put in their login name and password which opens a customers form. I want customers form to open with only a particular month's records for that sales rep.
What I want to do is
1) Open records for the sales rep who is loging in. (This part works).
2) Open only the records where RunMonth = #6/1/2004# when the customers form opens. (This is what I'm trying to add to the code).
(RunMonth is a text field on the form, its control source is RunMonth from the customers table which is the customers form's control source).
How do I add a filter to the code I have below to make it work?
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim conDB As ADODB.Connection
Dim rstblReps As ADODB.Recordset
Dim strPassword As String
Set conDB = New ADODB.Connection
conDB.Provider = "Microsoft.Jet.OLEDB.4.0"
conDB.Open "\\Backup\Departments\Mrkt\Telemarketing_Database\CustomerCallServiceTracking.mdb", "Admin", ""
Set rstblReps = New ADODB.Recordset
rstblReps.Open "select Password from tblReps where [Rep#]=" & Me![Combo4], conDB
strPassword = Trim(rstblReps!Password & "")
rstblReps.Close
Set rstblReps = Nothing
conDB.Close
Set conDB = Nothing
Text5.SetFocus
If strPassword = Trim(Text5.Value & "") Then
stDocName = "frmCustomers"
If Me![Combo4] <> 9 Then '9 = Admin
stLinkCriteria = "[Rep#]=" & Trim(Me![Combo4].Column(0))
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName
DoCmd.Maximize
End If
Else
MsgBox "Wrong Password"
End If
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click
End Sub
What I want to do is
1) Open records for the sales rep who is loging in. (This part works).
2) Open only the records where RunMonth = #6/1/2004# when the customers form opens. (This is what I'm trying to add to the code).
(RunMonth is a text field on the form, its control source is RunMonth from the customers table which is the customers form's control source).
How do I add a filter to the code I have below to make it work?
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim conDB As ADODB.Connection
Dim rstblReps As ADODB.Recordset
Dim strPassword As String
Set conDB = New ADODB.Connection
conDB.Provider = "Microsoft.Jet.OLEDB.4.0"
conDB.Open "\\Backup\Departments\Mrkt\Telemarketing_Database\CustomerCallServiceTracking.mdb", "Admin", ""
Set rstblReps = New ADODB.Recordset
rstblReps.Open "select Password from tblReps where [Rep#]=" & Me![Combo4], conDB
strPassword = Trim(rstblReps!Password & "")
rstblReps.Close
Set rstblReps = Nothing
conDB.Close
Set conDB = Nothing
Text5.SetFocus
If strPassword = Trim(Text5.Value & "") Then
stDocName = "frmCustomers"
If Me![Combo4] <> 9 Then '9 = Admin
stLinkCriteria = "[Rep#]=" & Trim(Me![Combo4].Column(0))
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName
DoCmd.Maximize
End If
Else
MsgBox "Wrong Password"
End If
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click
End Sub