Printing Report on Recordset Using "Filter by Form" - Error Message

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
 
S

Stepney_Clint

Vance,

I don't know why your technique is not working for you this time but it did
solve a the exact same problem I have been struggling with. Here is what I
did in the procedure called by the OnClick event for my runreport button:

If Screen.ActiveForm.FilterOn = True Then
DoCmd.OpenReport "rpt Issues (filtered)", acViewPreview, ,
Screen.ActiveForm.Filter
Else
DoCmd.OpenReport "rpt Issues (filtered)", acViewPreview
End If

Thanks for the pointer!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top