Update query after report prints (1 Viewer)

D

D B Lawson

Guest
I have a report which looks to a query for any records that haven't been printed, defined by a Yes/No in a check box. Once the report opens to view those records not printed already, I run an update query to put a check in those records. Trouble is the update query is executing before all the records are printing so, I'm only getting two records to print but, say, five unchecked ones are checking. The code I'm using is:
DoCmd.OpenReport stRptName, acViewPreview, "tblName", "[fieldName] = 0"
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdate"
DoCmd.SetWarnings True

I'm sure the update query is the problem because if I blank that out, all the records print ok.

Any ideas?

[This message has been edited by D B Lawson (edited 03-25-2001).]
 
R

Rich

Guest
Use DoCmd.RunSql "Update etc, in the close event of your report. To get the SQL statement simply select view SQL of your query in design view copy and paste.
HTH
 

AccessUser

Registered User.
Local time
Today, 07:44
Joined
Mar 28, 2001
Messages
35
The previously submitted solution is correct, but the reason why this is necessary is because of multitasking. Access performs the command to open the report, then continues on performing the rest of the commands in the procedure even though the OpenReport command is still processing. Thus the table gets updated before the report finishes printing.
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 07:44
Joined
Jun 16, 2000
Messages
1,954
Is this one of those situations where inserting:

DoEvents

in between the two operations will force Access to finish one before starting the other?
 
D

D B Lawson

Guest
An update. Thanks for your suggestion, Rich, which I tried. It didn't resolve the problem unfortunately. However, we discovered that if we sent the report straight to the printer without previewing it first, it prints the correct number of letters. That will have to do just now. I'll try Mike's DoEvent code and see what happens.

Dawn
 

Users who are viewing this thread

Top Bottom