Updating records after printing

G

Guest

I am new to Access, but trying to learn fast. I'm really stuck with a
'newbie' report question.

My form has a button that I use to print receipts using the code below. The
report is filtered to only print for those whose Yes/No field Request = True.

Sub cmdprintReceipts_Click
DoCmd OpenReport "rptReceipts", acViewPreview
chkboxRequest = False 'rec source is Request
txtNumReceiptsIssued = txtNumReceiptsIssued + 1
End Sub

Here's my problem
a) I want to reset 'chkboxRequest' and update 'txtNumReceiptsIssued' for
all of the records printed. It is only doing this for the first record.
b) I only want these updatings to happen if the report is ACTUALLY PRINTED.
If I cancel the 'preview' without printing, no changes should take place.

I'd really appreciate an assist with this. Thanks.
 
M

Marshall Barton

Victoria said:
I am new to Access, but trying to learn fast. I'm really stuck with a
'newbie' report question.

My form has a button that I use to print receipts using the code below. The
report is filtered to only print for those whose Yes/No field Request = True.

Sub cmdprintReceipts_Click
DoCmd OpenReport "rptReceipts", acViewPreview
chkboxRequest = False 'rec source is Request
txtNumReceiptsIssued = txtNumReceiptsIssued + 1
End Sub

Here's my problem
a) I want to reset 'chkboxRequest' and update 'txtNumReceiptsIssued' for
all of the records printed. It is only doing this for the first record.
b) I only want these updatings to happen if the report is ACTUALLY PRINTED.
If I cancel the 'preview' without printing, no changes should take place.


You need to use a separate mechanism to do this. Even if
you have a "Print" button to distinguish from a "Preview",
there is no guarantee the printing was successful (paper
jam, no toner/ink, accidentially discarded, etc).

A standard approach is to use a date/time field (named
PrintTime) instead of a yes/no field in the table. Once
the appropriate records can be determined, use an Update
query to set all the selected record's PrintTime field. The
printing can then be done without concern for additional
"Printed" indicators. If a printout fails for whatever
reason, you can generate another copy simply by filtering
on the date/time field.
 
G

Guest

I'll try that. Sounds good!

Marshall Barton said:
You need to use a separate mechanism to do this. Even if
you have a "Print" button to distinguish from a "Preview",
there is no guarantee the printing was successful (paper
jam, no toner/ink, accidentially discarded, etc).

A standard approach is to use a date/time field (named
PrintTime) instead of a yes/no field in the table. Once
the appropriate records can be determined, use an Update
query to set all the selected record's PrintTime field. The
printing can then be done without concern for additional
"Printed" indicators. If a printout fails for whatever
reason, you can generate another copy simply by filtering
on the date/time field.
 
G

Guest

Marshall - thanks for your quick reply. Do you have any hints re the a) part
of my question?

thankyou
 
M

Marshall Barton

I was trying to explain that those updates would not be
reliable. The only way to tell if something was
successfully printed is for a human to retrieve the paper
from the printer and look at it to decide if if it is
acceptable. I suppose that you could provide another button
to confirm the print is acceptable, but I don't see how this
would be especially useful. If you really want to do
something like this, you can do it in the same Update query
that I suggested before. The code would be something like

Dim db As Database
Dim strSQL As String
Set db = CurrentDb()
strSQL = "UPDATE table SET PrintTime = Now(), " & _
"Request = False"
db.Execute strSQL, dbFailOnError

Set db = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top