|
请看northwind.mdb的订单窗体打印发票的例子:
1.printInvoce按钮:
Sub PrintInvoice_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_PrintInvoice_Click
Dim strDocName As String
strDocName = "Invoice"
' Print Invoice report, using Invoices Filter query to print
' invoice for current order.
DoCmd.OpenReport strDocName, acViewNormal, "Invoices Filter" '********here
Exit_PrintInvoice_Click:
Exit Sub
Err_PrintInvoice_Click:
' If action was cancelled by the user, don't display an error message.
Const conErrDoCmdCancelled = 2501
If (Err = conErrDoCmdCancelled) Then
Resume Exit_PrintInvoice_Click
Else
MsgBox Err.Description
Resume Exit_PrintInvoice_Click
End If
End Sub
2."Invoices Filter" query:
SELECT DISTINCTROW Invoices.*
FROM Invoices
WHERE (((Invoices.OrderID)=[Forms]![Orders]![OrderID]));
|
|