Print all records in a form

  • Thread starter Thread starter Phil Hellmuth
  • Start date Start date
P

Phil Hellmuth

I want to programmatically print all records within a form. To print
just the current record, I can use DoCmd.PrintOut. What do I use to
print all records?

Thanks in advance.
 
Typically you would use a Report.
Doesn't the PrintOut take a few arguments such as start and end pages?
 
I want to programmatically print all records within a form. To print
just the current record, I can use DoCmd.PrintOut. What do I use to
print all records?

Thanks in advance.

Two problems here:

- Forms don't contain records. Tables contain records; a Form is just
a tool to edit those records.
- Forms aren't designed for printing; Reports are much better.

Just create a Report based on your table, or (better) a query
selecting those fields or records that you wish to print. You can put
a command button on the Form to launch the report.

John W. Vinson[MVP]
 
John, You touched on my question -- I have a form that with a print report
button; however, it prints all records. I want it to print just the record I
am viewing on the form. How do I accomplish that?

TY,

Kelvin
 
John, You touched on my question -- I have a form that with a print report
button; however, it prints all records. I want it to print just the record I
am viewing on the form. How do I accomplish that?

TY,

Kelvin

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'

Change acViewPreview to acViewNormal to print the report without first
previewing it.
 
Back
Top