Y
YFH
I am trying to print a single record from a form into a report.
The form is called formContract (based on a table called Contract) and
includes 2 subforms: formContract_Color and formContract_Price. The two
subforms basically summarize the items on the contract by color and by
price, respectively, and they are based on two tables Contract_Color
and Contract_Price. It's a one-to-many relationship between Contract
and Contract_Color/Contract_Price, and on the form they're linked by
master/child key Contract_ID.
The related report is called rptContract. I put a command button in the
form that opens the related record in report preview mode
(DoCmd.OpenReport stDocName, acViewPreview, ,
"[Order_ID]=Forms!formContract!cmbSelectOrder"
). I used the wizard to create 2 subreports in rptContract, based on
formContract_Color and formContract_Price.
I've designed the report so that each record can be printed on a single
page. I've also made sure that the report length and width plus margins
don't exceed the page.
The problem happens when I try to print the report. Instead of printing
one page for the selected record, it prints X pages, where X
corresponds to the number of corresponding records in Contract_Color.
Only the first page is what I want, containing all the information from
both subforms. All the other pages are identical to the first one,
except the subform information is missing (blank). For example, if the
contract I want to print has 20 color groups, 20 pages are printed.
Does anyone know the cause of this problem? Do I need to put in code
that specifies the subreports to be printed (even though I have defined
the master/child keys in both the form and the report)?
Thanks,
YH
The form is called formContract (based on a table called Contract) and
includes 2 subforms: formContract_Color and formContract_Price. The two
subforms basically summarize the items on the contract by color and by
price, respectively, and they are based on two tables Contract_Color
and Contract_Price. It's a one-to-many relationship between Contract
and Contract_Color/Contract_Price, and on the form they're linked by
master/child key Contract_ID.
The related report is called rptContract. I put a command button in the
form that opens the related record in report preview mode
(DoCmd.OpenReport stDocName, acViewPreview, ,
"[Order_ID]=Forms!formContract!cmbSelectOrder"
). I used the wizard to create 2 subreports in rptContract, based on
formContract_Color and formContract_Price.
I've designed the report so that each record can be printed on a single
page. I've also made sure that the report length and width plus margins
don't exceed the page.
The problem happens when I try to print the report. Instead of printing
one page for the selected record, it prints X pages, where X
corresponds to the number of corresponding records in Contract_Color.
Only the first page is what I want, containing all the information from
both subforms. All the other pages are identical to the first one,
except the subform information is missing (blank). For example, if the
contract I want to print has 20 color groups, 20 pages are printed.
Does anyone know the cause of this problem? Do I need to put in code
that specifies the subreports to be printed (even though I have defined
the master/child keys in both the form and the report)?
Thanks,
YH