print just curent record of the form

  • Thread starter Thread starter PM
  • Start date Start date
P

PM

I have put a command button on a form to print record.
The code line is DoCmd.PrintOut
But how do I limit this to print based on condition such
as "where EmployeeAge =20" or may be just print currently
displayed record?

Please help

Thanks.
 
I have put a command button on a form to print record.
The code line is DoCmd.PrintOut
But how do I limit this to print based on condition such
as "where EmployeeAge =20" or may be just print currently
displayed record?

Forms really aren't designed for printing, and the PrintOut method is
pretty limited.

I'd suggest that you create a Report (you can save the form as a
report to salvage your design effort). The Command Button Wizard has
an option to open a report; in at least some versions you get the
option of limiting that report to the current record. If you don't get
that option it's easy enough to add - just edit the VBA code in the
command button's click event so that the OpenReport line is something
like

DoCmd.OpenReport strDocument, WhereCondition:="[ID] = " & Me!txtID

using your own field and control names.
 
Back
Top