PRINTING REPORT FROM A FORM

  • Thread starter Thread starter DAN
  • Start date Start date
D

DAN

Hello, I need to print a report from a form, and I need
it to only print the current record that the form is set
to. Can anyone enlighten me as to how to do this? Is
there a way to pass a variable from a form into a query
used for the report, or should I do it some other way?
Thanks for the help.
 
DAN said:
Hello, I need to print a report from a form, and I need
it to only print the current record that the form is set
to. Can anyone enlighten me as to how to do this? Is
there a way to pass a variable from a form into a query
used for the report, or should I do it some other way?
Thanks for the help.

Dan,
You can use a query, or just open the report with a where clause right
from the form.
Your table should have a unique prime key field.
Assuming this field is included in the field's shown on the form, add a
command button to the form.
Code it's click event:

DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes [RecordID] is the name of the prime key field, and
that it is a Number datatype.

Change "ReportName" to the actual name of your report. Change [RecordID]
to the actual name of the prime key field.

Look up in Access help:
Where clause + Restrict data to a subset of records
for how to write a where clause for different data types.
 
Cool, thanks for the help, it worked great. One more
question maybe you know though. Do you know how to print
a report, but instead of just printing, making the print
dialog box appear (as if you pressed Ctrl+P). Thanks.

-----Original Message-----


Dan,
You can use a query, or just open the report with a where clause right
from the form.
Your table should have a unique prime key field.
Assuming this field is included in the field's shown on the form, add a
command button to the form.
Code it's click event:

DoCmd.OpenReport "ReportName",
acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes [RecordID] is the name of the prime key field, and
that it is a Number datatype.

Change "ReportName" to the actual name of your report. Change [RecordID]
to the actual name of the prime key field.

Look up in Access help:
Where clause + Restrict data to a subset of records
for how to write a where clause for different data types.

--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.
 
Back
Top