Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Screen

Status
Not open for further replies.

CLOS

MIS
Jan 30, 2002
23
0
0
US
Help! Help! Help!

I'm trying to set-up a command button that will print
a form and the record displayed on the form. How do
I code this to make it happen? Let me reiterate. What
I want to do is click on a command button that will print
the form and the data record displayed in the form. How do I do this.
 
Clos,

Try this:
docmd.printout
I think this will do what you want.

HTH,
Eric
 
The Docmd.Printout command will print the form with
record on it, but it's the first record in the table and
not the record that was selected for print. I need to
print out the exact record that appears on the form and
not the first record in the table.
 
For what its worth I would not normally print a form record as it is slow because the entire form image is printed and expensive because you use a lot of ink printing the image. I would prefer to create a Report to print the record.

However, if you are determined then to make Printout work the way you want just alter the Docmd.Printout line to read Docmd.Printout acSelection

If your form is coloured or shaded you might try changing the form Detail back colour temporarily to white.

If you set up a command button to run the Printout method using the Button Wizard then you should have a click event for the button something like the code below but without the bits in red which you should add to get a single record and speedier printing.


Private Sub Command9_Click()
On Error GoTo Err_Command9_Click
Dim DetailColor As Long
DetailColor = Me.Detail.BackColor
Me.Detail.BackColor = 16777215

Dim stDocName As String
Dim MyForm As Form

stDocName = "frmStock"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut acSelection
DoCmd.SelectObject acForm, MyForm.Name, False

Me.Detail.BackColor = DetailColor
Exit_Command9_Click:
Exit Sub

Err_Command9_Click:
MsgBox Err.Description
Resume Exit_Command9_Click

End Sub


regards
Rod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top