V
Vance
Hello. I am having a problem with a procedure that I have used
successfully in the past...
I want to be able to filter my records using the "Filter by Form"
feature, then click a command button to print a report based on the
filtered recordset. I have been able to do this with previous
databases in the past using the following procedure but, for some
reason, I am now getting a "parameter value" message when I attempt
this with this new database... I'm not sure what my problem is.
The procedure I used is as follows:
1. I created my table, my form (MyFormName), and my report
(MyReportName).
2. I then created a command button (with the wizard deselected) and
named it "cmdPrintReport." I then clicked the Code button on the
Form Design toolbar. When Access opened the form's module, I
declared a module-level variable named iFilterType by adding the
following statement to the form's General Declaration's area (I
inserted this line above the "Option Compare Database"):
Dim iFilterType As Integer
3. After declaring that variable, I selected "cmdPrintReport" from
the module window's Object dropdown list ("Click" Procedure), and
entered the procedure shown below at the insertion point:
Dim frm As Form
Set frm = Forms!MyFormName
If iFilterType = acApplyFilter Then
DoCmd.OpenReport "MyReportName", acViewPreview, , frm.Filter
Else
DoCmd.OpenReport "MyReportName", acViewPreview
End If
4. Next, I continued writing code by choosing "Form" from the Object
dropdown list and selected "ApplyFilter" from the Procedure dropdown
list.
At the insertion point, I typed the statement:
iFilterType = ApplyType
5. I then saved and closed the module.
Unfortunately, however, I get an error message when I click the
command button to print a report after filtering the records using
"Filter by Form." The message says: "Enter Parameter Value:
TblEmployees.fldEmployeeLastName" (which is the field on which I
filtered the records). When I click "OK" the report shows no records.
Does anyone know what I have done wrong?
Thanks!
Cannon
successfully in the past...
I want to be able to filter my records using the "Filter by Form"
feature, then click a command button to print a report based on the
filtered recordset. I have been able to do this with previous
databases in the past using the following procedure but, for some
reason, I am now getting a "parameter value" message when I attempt
this with this new database... I'm not sure what my problem is.
The procedure I used is as follows:
1. I created my table, my form (MyFormName), and my report
(MyReportName).
2. I then created a command button (with the wizard deselected) and
named it "cmdPrintReport." I then clicked the Code button on the
Form Design toolbar. When Access opened the form's module, I
declared a module-level variable named iFilterType by adding the
following statement to the form's General Declaration's area (I
inserted this line above the "Option Compare Database"):
Dim iFilterType As Integer
3. After declaring that variable, I selected "cmdPrintReport" from
the module window's Object dropdown list ("Click" Procedure), and
entered the procedure shown below at the insertion point:
Dim frm As Form
Set frm = Forms!MyFormName
If iFilterType = acApplyFilter Then
DoCmd.OpenReport "MyReportName", acViewPreview, , frm.Filter
Else
DoCmd.OpenReport "MyReportName", acViewPreview
End If
4. Next, I continued writing code by choosing "Form" from the Object
dropdown list and selected "ApplyFilter" from the Procedure dropdown
list.
At the insertion point, I typed the statement:
iFilterType = ApplyType
5. I then saved and closed the module.
Unfortunately, however, I get an error message when I click the
command button to print a report after filtering the records using
"Filter by Form." The message says: "Enter Parameter Value:
TblEmployees.fldEmployeeLastName" (which is the field on which I
filtered the records). When I click "OK" the report shows no records.
Does anyone know what I have done wrong?
Thanks!
Cannon