Solved: Access - Form button prints entire DB not the single record I want.

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
Okay forgive me as I NEVER want to touch databases. My wife only does little things in DB's and god bless her made a wonderful DB for us to keep track of our email accounts.

The problem is 1 button she made actually prints out ALL records to the printer instead of the one showing on the screen. THis is as far as her knowledge gets her.

Now when I look at the button in the form the name is - cmdEmailLogPrintForm

and when I look at the vb I see that it has -

Private Sub cmdEmailLogPrintForm_Click()
On Error GoTo Err_cmdEmailLogPrintForm_Click


DoCmd.PrintOut

Exit_cmdEmailLogPrintForm_Click:
Exit Sub

Err_cmdEmailLogPrintForm_Click:
MsgBox Err.Description
Resume Exit_cmdEmailLogPrintForm_Click

End Sub

Now I am fairly good at decyphering things and it seems to me the problem is with DoCmd.PrintOut

Is there any way to get this so it only prints what is currently showing in the form window NOT everything in the DB?

I have already cleaned the few other snafus I have with the DB but this one is not as minor as the others were (the others were just view layouts).
 

OBP

Joined
Mar 8, 2005
Messages
19,896
You are correct the DoCmd.PrintOut is not the correct way to print the current record.
The best method is to either save the form as a report or create a report with the same fields.
The report's data source should be a query that uses the current form record as it's criteria.
It is usual to use the form's current record's key field to "filter" the query.
This means putting in the criteria row of the query

Forms![Form Name]![key Field Name]

where form name and key field name are those used on your form.
 

StumpedTechy

Thread Starter
Joined
Jul 7, 2004
Messages
7,235
Actually I found an easy way -

RunCommand acCmdSelectRecord
DoCmd.PrintOut acSelection, 1, 1, acHigh, 1

this then makes it so the record I have up is the one that prints out and i don't have to mess with queries... which I know less about than VB :)

Thanks for the look though.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top