B
Bruce
I have recently received some help from this newgroup in
setting up a form and printing the related report. In one
instance I designed a form for entering information, and a
report for printing it. I wanted to print the currently
displayed record only, and somebody sent the following
code, which I attached to a command button on the form.
Private Sub cmdPrintForm_Click()
'Open the report to display only the current record
Dim DocName As String
Dim LinkCriteria As String
stLinkCriteria = "[ID]=" & Me![ID]
stDocName = "rptSpecReview"
DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria
Exit Sub
End Sub
cmdPrintForm is the command button on the form, [ID] is
the autonumber unique identifier for the record, and
rptSpecReview is the report that is printed.
Several questions: This is a very simple database. The
report draws information from a single form, which in turn
is associated with a single table (or query). I have
heard that reports are for printing and forms are for
entering information, but in this case what is the value
of a report that duplicates every field in the form? Any
reason why I shouldn't just print directly from the form,
by use of a Print button on the form?
Assuming there is a reason to have a separate report, the
code above works fine in printing the report on the
default printer. However, different users in different
parts of the facility will be printing this form, and I
would like them to be able to choose a printer. How can
this be done?
I can also set up on the form a button to preview the
report, but when it comes time to print there are some
issues. There is no ready method for putting a Print
button on the report (somebody suggested code to add a
floating toolbar, but that is somewhat cumbersome, and
anyhow I couldn't get it to work). I know the user can
print from a toolbar button, so this is not that big a
concern. However, the print command defaults to printing
all records, and even when Selected Record is checked in
the print dialog, the page numbering is for all of the
records, so that Page 1 of the selected record might show
it as Page 11 of 233 or something.
Ideal situation would be for the user to preview the
reprot for the selected record, then print it with page
numbering such that the first page is always Page 1.
Almost as good is to allow the user to select the printer
within the context of the code above, which produces the
correct page numbering.
setting up a form and printing the related report. In one
instance I designed a form for entering information, and a
report for printing it. I wanted to print the currently
displayed record only, and somebody sent the following
code, which I attached to a command button on the form.
Private Sub cmdPrintForm_Click()
'Open the report to display only the current record
Dim DocName As String
Dim LinkCriteria As String
stLinkCriteria = "[ID]=" & Me![ID]
stDocName = "rptSpecReview"
DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria
Exit Sub
End Sub
cmdPrintForm is the command button on the form, [ID] is
the autonumber unique identifier for the record, and
rptSpecReview is the report that is printed.
Several questions: This is a very simple database. The
report draws information from a single form, which in turn
is associated with a single table (or query). I have
heard that reports are for printing and forms are for
entering information, but in this case what is the value
of a report that duplicates every field in the form? Any
reason why I shouldn't just print directly from the form,
by use of a Print button on the form?
Assuming there is a reason to have a separate report, the
code above works fine in printing the report on the
default printer. However, different users in different
parts of the facility will be printing this form, and I
would like them to be able to choose a printer. How can
this be done?
I can also set up on the form a button to preview the
report, but when it comes time to print there are some
issues. There is no ready method for putting a Print
button on the report (somebody suggested code to add a
floating toolbar, but that is somewhat cumbersome, and
anyhow I couldn't get it to work). I know the user can
print from a toolbar button, so this is not that big a
concern. However, the print command defaults to printing
all records, and even when Selected Record is checked in
the print dialog, the page numbering is for all of the
records, so that Page 1 of the selected record might show
it as Page 11 of 233 or something.
Ideal situation would be for the user to preview the
reprot for the selected record, then print it with page
numbering such that the first page is always Page 1.
Almost as good is to allow the user to select the printer
within the context of the code above, which produces the
correct page numbering.