Delay code execution

P

Paul Cram

I have a report that includes a sub report. The sub report calculates totals
based upon the record displayed in the form. I have code that executes and
calculates these and stores the values in a table. The sub report looks at
this table for the data. If I run the code so that the code runs and then
calls the report it fails to display the subreport for the first record. If I
step through the code it works fine. Is there a way to delay the calling of
the report after execution of the code as this appears to be a timing problem.
 
S

strive4peace

Save Record, DoEvents
---


Hi Paul,

is the record in the subform being SAVED before you open the report?

'~~~~~~~~~~~
if me.subform_controlnam.form.dirty then
me.subform_controlnam.form.dirty = false
end if
'~~~~~~~~~~~

if this does not do the trick, you can throw this in there

DoEvents

~~~ DoEvents ~~~

DoEvents is used to make VBA pay attention to what is currently
happening and look to see if the OS (Operating System) has any requests.

ie: if you have a loop and want to be able to BREAK it with CTRL-BREAK,
put DoEvents into the loop

DoEvents will also update values written to a form by a general
procedure or code behind another form or report

A DoEvents is done when you use MsgBox, or are stepping through code
(since it has to pay attention to the keyboard)

It is a good way to say, "Wake Up!"




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
P

Paul Cram

There isn't a sub form. The table is populated from code via an ado
recordset. All of this code executes before the report is called. The Sub
report which is populated from this table doesn't popultae for the first
record but does for the second. Each record is an invoice and is displayed
one per page. The sub report is in the Invoice number footer. If I put a
break in before the report is called and step through it works properley
henace the reqiuirement to pause after populating the table but before
calling the report.

Regards
Paul
 
S

strive4peace

Hi Paul,

subform or not, the point is that you need to save the data before
opening the report.

What is the code you are using to process the report? If you post it,
we may see something that needs to be added or modified.

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

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