form printing all the forms!!

Rpm1957

Registered User.
Local time
Today, 09:33
Joined
Feb 3, 2012
Messages
19
i have command button on my form to print the current form. however when i selected it prints all the forms. how do i get it to just print the current form that i am looking at and also print it in landscape only?
 
Easiest way is to add a command button to your form with the Wizard active, and then choose the appropriate options. The wizard will generate code for the button's click event that will print just the current record.

Otherwise, you can modify the code for the existing button so that it filters for the current record.

Sadly, MSAccess 2010's wizard has the vile habit of creating macros, but they can be converted to VB:

Code:
Option Compare Database
Option Explicit
 
'------------------------------------------------------------
' cmdPrintRecord_Click
'
'------------------------------------------------------------
 
Private Sub cmdPrintRecord_Click()
 
On Error GoTo cmdPrintRecord_Click_Err
 
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdPrintSelection
 
cmdPrintRecord_Click_Exit:
    Exit Sub
cmdPrintRecord_Click_Err:
    MsgBox Error$
    Resume cmdPrintRecord_Click_Exit
End Sub
 
Last edited:
I use ac2003 so the following might not be of use.

Private Sub Command54_Click()
On Error GoTo Err_Command54_Click
Printer.Orientation = acPRORLandscape
DoCmd.PrintOut

Exit_Command54_Click:
Exit Sub
Err_Command54_Click:
MsgBox Err.Description
Resume Exit_Command54_Click
end sub
 

Users who are viewing this thread

Back
Top Bottom