Invoice Revisited

  • Thread starter Thread starter Saxman
  • Start date Start date
S

Saxman

The following code is attached to command button on form 'frmPrintInvoice'.

It prints all the relevant customer and order information for me on page 1 of the
report 'Invoice'

'frmPrintInvoice' has a combo box which one has use in order to select an order for
printing. The combo has the following SQL data in the row source:-

SELECT [First Order] FROM Orders ORDER BY [First Order] DESC;

All works fine except that the printer churns out vestiges of print on several other
pages. (It will probably be more when further orders are added).

How can I get the command button to only print page 1? Or give me the chance to
send the command instruction to the printer driver, where I can select only page 1?

The following code was written by Ken Snell (MVP) who has been very helpful with my
problem. If I can solve this, it will complete the job!

Excuse me for being green, I'm not as brilliant as some.

..........................................................................
Option Compare Database

' Start of code
Private Sub cmdPrint_Click()
If Len(Me.cboInvNumber.Value & "") > 0 Then
DoCmd.OpenReport "Invoice", _
, , "[First Order]=" & Me.cboInvNumber.Value
' if [First Order] is a text field, use the next "two" code steps in
' place of the "two" steps above
' DoCmd.OpenReport "Invoice", _
' , , "[First Order]='" & Me.cboInvNumber.Value & "'"
Else
MsgBox "Select an order number.", vbInformation, _
"Select Order Number"
End If
End Sub
' End of code
Private Sub Preview_Invoice_Click()
On Error GoTo Err_Preview_Invoice_Click

Dim stDocName As String

stDocName = "Invoice"
DoCmd.OpenReport stDocName, acPreview

Exit_Preview_Invoice_Click:
Exit Sub

Err_Preview_Invoice_Click:
MsgBox Err.Description
Resume Exit_Preview_Invoice_Click

End Sub

............................................................................
--
 
You need to open the report in Print Preview, then print it out. Try this
change:

DoCmd.OpenReport "Invoice", acViewPreview, , _
"[First Order]=" & Me.cboInvNumber.Value
DoCmd.PrintOut acPages, 1,1
 
Arvin said:
DoCmd.OpenReport "Invoice", acViewPreview, , _
"[First Order]=" & Me.cboInvNumber.Value
DoCmd.PrintOut acPages, 1,1

That works fine. I am very grateful to you.

--
 
Back
Top