Selected Record Print ???

J

Jay Wilson

I have placed a "Print" button on a form. When I press the button, I want
to print only the record that I am currently looking at. When I press the
button, I get all records in the table.

I tried the following, to limit the record to the currectly selected record
and I still get all records.

DoCmd.PrintOut acSelection

I then tried the following and get an error message that the Currently
Selected isn't available.

RunCommand acCmdSelectRecord
DoCmd.PrintOut acSelection

What am I doing wrong?

Thanks
 
M

Mike Painter

Jay said:
I have placed a "Print" button on a form. When I press the button, I
want to print only the record that I am currently looking at. When I
press the button, I get all records in the table.

I tried the following, to limit the record to the currectly selected
record and I still get all records.

DoCmd.PrintOut acSelection

I then tried the following and get an error message that the Currently
Selected isn't available.

RunCommand acCmdSelectRecord
DoCmd.PrintOut acSelection

Run your report from a query.
Even if you don't print it have the record key in the query.
The criteria for that field in the query will be
Forms!YourFormName!YourKeyFieldonForm
 
A

Albert D. Kallal

I would strongly suggest you built a report.

Once you made the report, then it is a simple matter to send the CURRENT
record to that report.


The code behind the button looks like:

me.Refresh ' write the record to disk for report
docmd.OpenReport "YourReprot",acViewPreview,,"id = " & me!id

The above will print the one record. If you remove the acViewPreview, then
you will not get a preview, and it goes right to the printer.
 

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