print just curent record of the form

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.
 
J

John Vinson

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.
 

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