M
Martin Cibulka
Greetings,
I've spend a couple hours banging my head against the wall and can't
figure
out why this isn't working.
I have a subform with a list and a form footer that has a text field
(txtSumAmount) showing the sum of one of the fields in the list
("=Sum([DepositLineAmount])"). In the Form_Current of the main form I
set
the RecordSource of the subform accordingly, and then I want to use
the new
value of txtSumAmount in some other calculations.
So I added the following function to my subform:
Public Sub GetTotal(dblPayments As Double)
dblPayments = Nz(Me.txtTotalPayments, 0)
End Sub
However - in Access 2000 this always returns 0, even if I explicitly
do a
Requery and Refresh on the subform, and even a
txtTotalPayments.Requery
before calling this function.
Now, the puzzling thing is that it works just fine if I set a
breakpoint on
the "dblPayments = ..." line and step over it - it then retrieves the
correct value! So it must be some kind of timing thing?
Am I doing something incorrectly? Is there a better way to get at the
sum
of a field in a list? I didn't want to use DSum() since it seems like
I'd
be running the same query twice.
Thanks!
Martin
I've spend a couple hours banging my head against the wall and can't
figure
out why this isn't working.
I have a subform with a list and a form footer that has a text field
(txtSumAmount) showing the sum of one of the fields in the list
("=Sum([DepositLineAmount])"). In the Form_Current of the main form I
set
the RecordSource of the subform accordingly, and then I want to use
the new
value of txtSumAmount in some other calculations.
So I added the following function to my subform:
Public Sub GetTotal(dblPayments As Double)
dblPayments = Nz(Me.txtTotalPayments, 0)
End Sub
However - in Access 2000 this always returns 0, even if I explicitly
do a
Requery and Refresh on the subform, and even a
txtTotalPayments.Requery
before calling this function.
Now, the puzzling thing is that it works just fine if I set a
breakpoint on
the "dblPayments = ..." line and step over it - it then retrieves the
correct value! So it must be some kind of timing thing?
Am I doing something incorrectly? Is there a better way to get at the
sum
of a field in a list? I didn't want to use DSum() since it seems like
I'd
be running the same query twice.
Thanks!
Martin