Form1"
combobox "cboModel"
Row Source
combobox "cboContactName"
quick explanation: I have a table named tblCOntacts and in this table i have 3 fields "LastName" and "FirstName" and "Initial" becuase i have multiple employess that have the same last names and sometimes same first and last name. So I have a query titled "Quer1" with 2 feilds in it titled:
"File AS" and "Contact Name". Each of these fields combines the first and last name into one field. one does it first name last name and the other last name first name.
and then on form1 i have two cmdbuttons "cmdApplyFilter" and "cmdRemoveFilter"
Here is the code:
So this is what happens.
I first open the report "rptContacts" then open the "form1"
i choose a model from the model box and leave the name area blank and click the "apply filter" button. this causes a small form "Enter parameter value" opens and wants me to input a model and then will do the same thing again for the contact name. If I enter values into it, the report comes up blank. Aslo the refresh button is not refreshing the filter. Any Ideas? If you need more info let me know.
Thanks
combobox "cboModel"
Row Source
Code:
SELECT [tblModel].[ID], [tblModel].[Model] FROM tblModel ORDER BY [Model];
Code:
SELECT [Query1].[Contact Name] FROM Query1 ORDER BY [Contact Name];
"File AS" and "Contact Name". Each of these fields combines the first and last name into one field. one does it first name last name and the other last name first name.
and then on form1 i have two cmdbuttons "cmdApplyFilter" and "cmdRemoveFilter"
Here is the code:
Code:
Option Compare Database
Option Explicit
Private Sub cmdApplyFilter_Click()
Dim strModel As String
Dim strContactName As String
Dim strFilter As String
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptContacts") <> acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build criteria string for Office field
If IsNull(Me.cboModel.Value) Then
strModel = "Like '*'"
Else
strModel = "='" & Me.cboModel.Value & "'"
End If
' Build criteria string for Department field
If IsNull(Me.cboContactName.Value) Then
strContactName = "Like '*'"
Else
strContactName = "='" & Me.cboContactName.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[Model] " & strModel & " AND [Query1].[ContactName] " & strContactName
' Apply the filter and switch it on
With Reports![rptContacts]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Private Sub cmdRemoveFilter_Click()
On Error Resume Next
' Switch the filter off
Reports![rptContacts].FilterOn = False
End Sub
So this is what happens.
I first open the report "rptContacts" then open the "form1"
i choose a model from the model box and leave the name area blank and click the "apply filter" button. this causes a small form "Enter parameter value" opens and wants me to input a model and then will do the same thing again for the contact name. If I enter values into it, the report comes up blank. Aslo the refresh button is not refreshing the filter. Any Ideas? If you need more info let me know.
Thanks