B
Bruce
This duplicates part of an earlier post in the Getting
Start forum, but after a couple of days I have not
received a reply, so I am reposting here.
I have recently received help from this newgroup in
setting up a form and printing the related report. I used
the wizard to set up the command button to print the
report, then incorporated suggestions until I came up with
the following:
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.RunCommand acCmdSaveRecord
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.
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 place 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 a big concern. However, the print
command defaults to printing all records, and even when
Selected Record is checked in the print dialog (more user
input than I would like to have anyway), the page
numbering is for all of the records, so that the first
page of the selected record might show as Page 11 of 33 or
something.
Ideal situation would be for the user to preview the
report for the selected record, then print it with page
numbering such that the first page of any record is Page 1.
Almost as good would be for the user to click on the
command button described above, select a printer, and have
the report print with numbering as described in preceding
sentence. Previewing the form before printing would be
nice, but is not required.
Start forum, but after a couple of days I have not
received a reply, so I am reposting here.
I have recently received help from this newgroup in
setting up a form and printing the related report. I used
the wizard to set up the command button to print the
report, then incorporated suggestions until I came up with
the following:
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.RunCommand acCmdSaveRecord
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.
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 place 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 a big concern. However, the print
command defaults to printing all records, and even when
Selected Record is checked in the print dialog (more user
input than I would like to have anyway), the page
numbering is for all of the records, so that the first
page of the selected record might show as Page 11 of 33 or
something.
Ideal situation would be for the user to preview the
report for the selected record, then print it with page
numbering such that the first page of any record is Page 1.
Almost as good would be for the user to click on the
command button described above, select a printer, and have
the report print with numbering as described in preceding
sentence. Previewing the form before printing would be
nice, but is not required.