Printing a single record

G

Guest

I have a form which has a command button on it to view the report linked to the data displayed on the form, when I click the button it opens the Report page but shows all the records, how do I get it to show one record and how do I then print out that one record, can any answers relating to VB be very basic as I don't habe any experience with it

Thanks

Craig.
 
R

Rick Brandt

Craig said:
I have a form which has a command button on it to view the report linked
to the data displayed on the form, when I click the button it opens the
Report page but shows all the records, how do I get it to show one record
and how do I then print out that one record, can any answers relating to VB
be very basic as I don't habe any experience with it

Look at the code your button is currently using. You should see that the
primary line is using the DoCmd.OpenReport method to cause the report to
open in preview mode. The OpenReport method also supports an optional
WHERE argument which is a string that looks like the WHERE clause of a
query without the word "WHERE" at the beginning.

You can use this WHERE argument to specify a filter for the report. You
need that filter to restrict the report to only the record currently
displayed on the form. If the Primary Key of the record on both the form
and report was a numeric field named [ID] then the syntax would look
like...

DoCmd.OpenReport "ReportName", acPreview, ,"[ID] = " & Me![ID]

If the [ID] of the current record was 123456 then this would be translated
to...

DoCmd.OpenReport "ReportName", acViewPreview, ,"[ID] = 123456"
 

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