Hi John,
Thanks for you help. The example below is close to what I need. Instead of
just ONE record I'd like to grab all record(s) that share the same [TO] I
have a control on my form that is named "TO" and it is the
one thing that ties a group of records together..example To: 23-Savanna my
problem becomes after I use the print button to print 23-savanna's report, I
may create and print 44-lexington...and bam I get 23-savanna plus
44-lexington and so on...major waste of paper. Just to be clear I want ONLY
CURRENT records. I know I coud open the print properties and select a print
range but I was hoping to do it in code behind a command button.
Thanks
Reports: Print only the current record to a report
Author(s)
Dev Ashish
(Q) I'm trying to print out only the current record from my form in a report
but each time all the records print out. How can I print only one record
using a report?
(A) Use the OpenReport's Where condition to specify your record. For
example, the following code placed behind a command button on the form would
use the RunID control on the form to restrict the Report to only one record.
'******************** Code Start ************************
Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere
'******************** Code End ************************
John Spencer said:
If you look at the record for report a and report b how do YOU know that
you should only print report b even though ther report a and report b
have the same date.
What IN THE RECORD tells you to print only report b? If you can't
determine it from the record then the computer cannot.
You can add another field to the table to do this. You might use
something like PrintDateTime and populate the field after you
successfully print the record. Or you might have a PrintDate field and
a print batch number field and populate them after you have successfully
printed.
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Richard wrote:
Hello forum, I need help printing reports...I have a form that I use to
create delivery memos. I print my reports from a query that only has one
critera which is >=date() in the date field. This works ok as long as all
reports are run at the same time. But if I print report A then create a new
memo report B they both print. Is there a way to have only pending record(s)
print? I'd like to have the code behind a command button. Thanks Richard