Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print multiple records in report based on a form...

Status
Not open for further replies.

MeisoT

Technical User
Apr 25, 2004
43
US
I know how to print a report based on the current record displayed on a form. I need to print a report based on all the records in the form's recordset but not all the records in the table's recordset.

For example, if I want to print all records for 02/19/05, there are some records in the table with this date, but I only want to print the ones that were just added using a form.

I've tried several different methods to no avail. Does anyone have any workable ideas? Thanks.
 
MeisoT
You could print the particular record that you have just added via the form, but your post seems to indicate that you might have added several at this particular entry time.

Are these the circumstances: you had added 3 records this morning with the date of 02/19/05, and you add another 3 records this afternoon, and it is only the 3 you added this afternoon that you wish to print?

If this is correct, ask yourself this question: How is the program to know that you want to print only the records added this afternoon? If it is not the date that identifies those, is there something else you can use as criteria?
If not, then you could, as I indicated in the first portion of this reply, print each individual record added this afternon at the very time you have just completed the entry...by using a command button to print only that record.

Tom
 
I'll second THWatson's comments, I'm not entirely sure what the question really is.

To get only the records in the forms recordset, you can use the form recordset, this will allow you to access only the records currently in the form recordset, based on link master/child, filters...

Here assuming a numeric identifier (primary key)

[tt]dim rs as dao.recordset
dim strWhere as string
set rs=me.recordsetclone
rs.movefirst
do while not rs.eof
strWhere = strWhere & rs!PKField.value & ","
rs.movenext
loop
strWhere = mid$(strWhere,1,len(strWhere)-1)
strWhere = "PKField IN (" & strWhere & ")"
docmd.openreport "rptName",acviewpreview,,strWhere[/tt]

If it's only the current date, use that as criterion in stead:

[tt]docmd.openreport "rptName",acviewpreview,,"yourdate = #" & format$(me!txtDate.value) & "#"[/tt]

If it's only the new records, I'd consider adding another field (Yes/no) to the recordsource of your form, which you toggle between Yes and No based on when it's printed.

- code is typed not tested, the first snippet requires Microsoft DAO 3.# Object Library to be referenced (in VBE - Tools | References) and assumes this is a mdb, not adp.

Roy-Vidar
 
Thanks RoyVidar. Your suggestion for using the form's recordset works great. That's exactly what I needed!


(p.s. to all - my apologies for the ambiguity of my question)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top