How do I create a button to print a report for a specific record?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a form that users can fill out. I want to include a command
button on the form that prints a report that I've created as well. The
problem I'm having is that I can't figure out how to print a report for a
single record. Right now, I can only get it to reports for every single
record in my database.

I've tried to creat a macro to do this, but no luck so far.

Any help would be appreciated.
 
I've created a form that users can fill out. I want to include a command
button on the form that prints a report that I've created as well. The
problem I'm having is that I can't figure out how to print a report for a
single record. Right now, I can only get it to reports for every single
record in my database.

I've tried to creat a macro to do this, but no luck so far.

Any help would be appreciated.

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'
 
I assume something on the form makes this particular record unique.
If so the in the click of the button add the code

DoCmd.OpenReport "Your Report Name", acViewNormal, , "[UniqueID] = " &
Me.UniqueID
 
Back
Top