waiting for a form to calculate

samcoinc

Registered User.
Local time
Today, 21:32
Joined
Sep 26, 2001
Messages
49
I have an odd problem. I have a form that is pretty intense. It is a costing form that allows users to pick operations needed to do a job as well as material and such. It calculates it on the fly and gives a price per part each time someting is changed. Now here is the problem. In the print button there is a refresh before the report is printed to make sure that every change that was made takes effect. This works fine and the report prints out perfectly.

Now sense the calculation to find the price takes multible querys and calculations I wanted to save the price per part in the main header table for future use when the report is printed. (I know this isn't a very good practice but it make my life easier on other aplications that use the price as I don't have to recalculate it each time from the data)

The problem is it looks like the form isn't done calculating before I write the result back to the table. I added a refresh button to the form to see what is going on and the final price changes twice before the actual price shows up. (it does a lot). So most of the time what get put back into the table is the wrong price.

What I am looking for is a way to pause the code until the form is done calcualting after a refresh. Then copy the final price back to the table. I have run in to this problem before where somthing doesn't get done before next line of code happens.

thanks
sam
 
Last edited:
G’day Sam.

You seem to be aware that storing the value is generally regarded as incorrect so I won’t comment further.

And so to the problem of waiting for the Refresh to complete: -
Usually the form Timer countdown does not occur while Access is involved in heavy calculations and you may be able to use this feature.

To test the situations try this: -
Create an OnTimer event with two lines of code…
Me.TimerInterval = 0
MsgBox "Here in OnTimer event."

And just before the refresh…
Me.TimerInterval = 1000
Me.Refresh

I can’t test it but what I suspect (hope) will happen is the MsgBox will popup 1 second after the calculations are complete.

If so then the final, correct, price should be available at the time of the MsgBox. To test it further I would be inclined to reduce the time to 1 millisecond just to see if the system breaks.

If not then I really have no other ideas.

Regards,
Chris.
 
Very cool idea.

thank you - I will try it and get back to you
sam
 

Users who are viewing this thread

Back
Top Bottom