Print Preview

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

Guest

I've added a Print preview feature to a form. How do I get this feature to
select only the current record for preview?
 
I've added a Print preview feature to a form. How do I get this feature to
select only the current record for preview?

Your table should have a unique prime key field.
In my example it is named [RecordID].

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

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

If, however, [RecordID] is Text Datatype, then use:

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

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "
Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'
 
Back
Top