DSUM question

BloodshotVandal

Registered User.
Local time
Today, 13:44
Joined
Nov 19, 2009
Messages
17
I have the following formula

Code:
Public Function TotalBalance()
    Me![intTotal] = DSum("[Total]", "qryMain", "[TransDate] <=#" & TotalDate & "#")
End Function

:
:

Private Sub intAmount_AfterUpdate()
     TotalBalance
End Sub

Private Sub intAmount_Change()
    TotalBalance
End Sub

Private Sub Form_Current()
    TotalBalance
End Sub

The thing is the Me![intTotal] value only updates when the next record is accessed but not immediately when the intAmount value is changed. Can someone help me figure out why the Me![intTotal] does not update when the intAmount value is changed?

Thanks
 
I have the following formula

Code:
Public Function TotalBalance()
    Me![intTotal] = DSum("[Total]", "qryMain", "[TransDate] <=#" & TotalDate & "#")
End Function

:
:

Private Sub intAmount_AfterUpdate()
     TotalBalance
End Sub

Private Sub intAmount_Change()
    TotalBalance
End Sub

Private Sub Form_Current()
    TotalBalance
End Sub

The thing is the Me![intTotal] value only updates when the next record is accessed but not immediately when the intAmount value is changed. Can someone help me figure out why the Me![intTotal] does not update when the intAmount value is changed?

Thanks

Try putting a new line
PHP:
Me.Requery
in the function after the DSUM... statement.

I think by default, the values will only change when the record is saved.
 
Hi,

Did you make sure that the AfterUpdate event is really defined for intAmount?

It happenned to me once that I had it in code but not in the properties in design mode...

You could also insert a breakpoint to make see if it is executed...

Simon B.
 
I think jdraw has got it... your data is not saved until you change record... so you are still querying the same data, no matter what is in your textbox...
 
Put a

If Me.Dirty Then Me.Dirty = False

in the line at the beginning of the TotalBalance function.
 
Okay, got it to work.
Thank you jdraw, SimonB1978, and boblarson your suggestions and advice.
 

Users who are viewing this thread

Back
Top Bottom