General discussion

Locked

Print report from Form in Access 2000

By AJD ·
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!!

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Print report from Form in Access 2000

by Magetower In reply to Print report from Form in ...

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

Collapse -

Print report from Form in Access 2000

by AJD In reply to Print report from Form in ...

Thanks, anyway!

Collapse -

Print report from Form in Access 2000

by mbarker734 In reply to Print report from Form in ...

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

Collapse -

Print report from Form in Access 2000

by AJD In reply to Print report from Form in ...

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

Collapse -

Print report from Form in Access 2000

by AJD In reply to Print report from Form in ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums