Discussion Locked

Print report from Form in Access 2000

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to print a Report from a button located on a Form. The Report must be limited to the record currently displayed on the Form. There are two fields on the Form that control the data that is to be displayed in the Report: a "MRNumber" field in the parent form and a "visit date" field in the child form.
The Report is based on a query.
I am using the following syntax in a Print Report button on the Form:

DoCmd.OpenReport stDocName, acNormal, , [MrNumber] = [Forms]![Patient Billing details]![MrNumber] And [Visit Date] = [Forms]![Patient Billing details]![Patient Billing sub1]![Visit Date]

The problem is the Report just ignores the Where clause and prints all records instead of the ones defined by the Form fields.
Do I need anything in the Query to allow it to accept the parameters of the Where statement?
Help!!

5 replies

by magetower

You need to place the variable in the Criteria area for the field you are trying to filter on in the query.

by mbarker734

You line will work. You are just missing some quotes.

DoCmd.OpenReport stDocName, acNormal, , "[MrNumber] = [Forms]![Patient
Billing details]![MrNumber] And [Visit Date] = [Forms]![Patient Billing
details]![Patient Billing sub1]![Visit Date]"

The where must be a string.

Good luck,

Mark

by ajd

You hit the nail on the head! Thanks very much. (I was so near, yet so far!)

This discussion is closed to new replies.