This is probably an odd question... Before our big fund-raising event, our
non-profit solicits donations. We gather names from past donors and from our
members. I've created an access database that tracks the donors/potential
donors. We send out letters in "batches"- when we get the names,
essentially. So, I'm wondering how I keep from sending the first batch of
letters out everytime I send out the following batch of letters.
I thought about a flag on the form and having the underlying report query
skip if the flag is yes. But not sure how to automate... Any suggestions
appreciated...
1) Add a new field to your table... Date/Time datatype. Name it
"DateSent".
Add a Group Header and a Group Footer to your report on the DonorID
field. Set the Group Header Force New Page property to Before Group.
(This will assure only one Donor on each page.)
Add the [DonorID] control to the group header (or in the Detail
Section). (You can make it not visible and close up the height of the
header and footer if you don't need to print those.)
Code the report's Declarations section and the Activate event and
GroupFooter Format events exactly as below:
Note: Your GroupFooter number may be different than mine. Use yours.
Option Compare Database
Option Explicit
Dim intPreview As Integer
---------------------
Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As
Integer)
If intPreview = 0 Then
Dim strSQL As String
strSQL = "Update YourTableName Set YourTableName.DateSent= #" _
& Date & "# Where YourTableName.[ID] = " & [ID] & ";"
CurrentDb.Execute strSQL, dbFailOnError
End If
End Sub
------------------------------
Private Sub Report_Activate()
intPreview = -1
End Sub
--------------------
Change the table name and field names in the strSQL above to match
what your actual table and field names are.
To actually print the report...`
Open the report from a command button on a form:
DoCmd.OpenReport "ReportName", acViewNormal, , "[DateSent] Is Null"
The above will print out and place the date in the table field for
that record.
Only records that do NOT have a date in the DateSent field will print.
If you Preview the report, the above records will NOT be updated, even
if you then click print from the preview window.
Caution: Be aware that though you have sent the report to the printer,
there is no guarantee that the reports have all been successfully
printed. Printers do run out of ink, paper, etc., or just die of old
age. :-(
Have fun....