print a report for current record

H

help!

I am having trouble printing a report based on the
current record on the form which also has a subform. I
found an article at Microsoft but it didn't work. I end
up printing all the records but I only want the one that
is active to show up in the report.

thanks.
 
F

Fons Ponsioen

Hi. This was a response to an earlier posting.
Add a Command Button to your Form. Code it's Click event:
DoCmd.OpenReport "yourReportName",acViewPreview, , "[Record
ID] = " & [RecordID]
The above assumes your table has a unique prime key field
named [RecordID] and it is of Number Datatype.
Change [RecordID] to whatever the actual name of that
field is.
Change acViewPreview to acViewNormal to print the report
without preview.
If [RecordID] is a Text Datatype then use:
"[RecordID] = '" & [RecordID] & "'"
If you run this report always to print the current record
from this form, you could built the filter directly into
the query on which the report is based.
Hope this helps.
Fons
 
G

Guest

thanks! That worked!!!
-----Original Message-----
Hi. This was a response to an earlier posting.
Add a Command Button to your Form. Code it's Click event:
DoCmd.OpenReport "yourReportName",acViewPreview, , "[Reco rd
ID] = " & [RecordID]
The above assumes your table has a unique prime key field
named [RecordID] and it is of Number Datatype.
Change [RecordID] to whatever the actual name of that
field is.
Change acViewPreview to acViewNormal to print the report
without preview.
If [RecordID] is a Text Datatype then use:
"[RecordID] = '" & [RecordID] & "'"
If you run this report always to print the current record
from this form, you could built the filter directly into
the query on which the report is based.
Hope this helps.
Fons
-----Original Message-----
I am having trouble printing a report based on the
current record on the form which also has a subform. I
found an article at Microsoft but it didn't work. I end
up printing all the records but I only want the one that
is active to show up in the report.

thanks.
.
.
 
Top