Code running too fast before Access performs calculation (1 Viewer)

Chromedome

Registered User.
Local time
Today, 06:34
Joined
Jan 10, 2008
Messages
14
Hi Everyone

Does anyone know how to get Access to perform all the default calcualtions before running a bit of code?

I'm finding that the code which passes calculated information to another control completes before Access has had time to complete it's own default calculations. Therefore it passes the old value rather than the new.

I've searched but can't find anything. Borland had the [DoDefault] to overcome this (I'm not knocking Access here, I'm still finding my way around it ;))

Hope someone can help

Regards

CD
 

Dennisk

AWF VIP
Local time
Today, 06:34
Joined
Jul 22, 2004
Messages
1,649
what default calculations?

It may be better if you explained what you are trying to acheive and post the code that your are using as the above makes no sense at all.
 

boblarson

Smeghead
Local time
Yesterday, 22:34
Joined
Jan 12, 2001
Messages
32,059
Actually, I think you just don't have your stuff in the correct events or something because it doesn't move to fast to recalculate. What events are you using and what code are you using?
 

Chromedome

Registered User.
Local time
Today, 06:34
Joined
Jan 10, 2008
Messages
14
Thanks for your interest...

I'm still in testing mode at the moment, but basically I have a SubForm for inputting 'LineItems' with [Qty] & [ListPrice]. With an [AfterUpdate] event on the [Qty] control I populate the [Total] control with [Qty] * [ListPrice] (OK so far)

In the Footer of the Subform I have a calculated control ([ToalSubList]) which does a [=Sum()] on the [Total] (OK so far)

I simply need to pass the results of the [TotalSubList] to a BOUND control [TotalJob] in the Main Form when the [Qty] control is updated (it works OK with an UNBOUND control). Here is where the problem lies: If I make the Footer of the SubForm visible and then do an update on one of the [Qty] controls, the [TotalJob] control updates before the [TotalSubList] gets updated, therefore the Old Value is passed and not the New Value.

The code is as follows: (the additional lines are there for testing purposes)
Private Sub Qty_AfterUpdate()
Dim Qtty As Control
Dim Ttl As Control
Dim Lst As Control
Dim TJ As Control
Dim TSL As Control
Dim TJL As Control

Set Qtty = Me.Qty
Set Ttl = Me.Total
Set Lst = Me.ListPrice
Set TSL = Me.TotalSubList
Set TJ = Forms.JobsMain.TotalJob
Set TJL = Forms.JobsMain.TotalJobList

Ttl = Qtty * Lst

RunCommand acCmdSaveRecord

TJ = TJL


'MsgBox ("TJL Value: " & TJL)
End Sub​

Thanks again for your interest and help

Regards

Mark
 

Users who are viewing this thread

Top Bottom