N
notoca
Hi
The following is code for a command button in a form. When
clicked it produces a report based upon the current record
of the form.:
The following procedure prints only the record that you
select from the Customers form in the sample database
Northwind.mdb.
Open the Customers form in Design view. Add a command
button to the form, and then set the following command
button properties:
Name: cmdPrintRecord
Caption: Print Record
OnClick: [Event Procedure]
Set the OnClick property to the following event
procedure:
Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String
strReportName = "rptPrintRecord"
strCriteria = "[CustomerID]='" & Me![CustomerID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, ,
strCriteria
End Sub
I would like to take this once step further. On my form I
have a unbound field that calculates the total cost of an
invoice. Now for the unusual bit. The total amount
calculated determines which one of two reports should be
printed. The criteria is if the amount is less than $51
then "report1" is used, otherwise if it is greater than
$50 then "report2" is used. I know this sounds wierd but
this is the system we have to work with.
So, is it possible to adjust this code to choose which
report to open based on the total amount of the invoice
record?
Thanks
notoca
The following is code for a command button in a form. When
clicked it produces a report based upon the current record
of the form.:
The following procedure prints only the record that you
select from the Customers form in the sample database
Northwind.mdb.
Open the Customers form in Design view. Add a command
button to the form, and then set the following command
button properties:
Name: cmdPrintRecord
Caption: Print Record
OnClick: [Event Procedure]
Set the OnClick property to the following event
procedure:
Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String
strReportName = "rptPrintRecord"
strCriteria = "[CustomerID]='" & Me![CustomerID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, ,
strCriteria
End Sub
I would like to take this once step further. On my form I
have a unbound field that calculates the total cost of an
invoice. Now for the unusual bit. The total amount
calculated determines which one of two reports should be
printed. The criteria is if the amount is less than $51
then "report1" is used, otherwise if it is greater than
$50 then "report2" is used. I know this sounds wierd but
this is the system we have to work with.
So, is it possible to adjust this code to choose which
report to open based on the total amount of the invoice
record?
Thanks
notoca