OnCurrent calculations

  • Thread starter Thread starter Al Camp
  • Start date Start date
A

Al Camp

Hello all...
I have a main form (frmMain) with a continuous subform (frmSubform). The
subform contains "disbursement" records against a frmMain form OrderAmt.
(basically... multiple subform entry of lengths of fabric vs. an OrderAmt).
When the Sum of subform disbursements (in a calculated field
[TotalDisbursed] in the subform footer) meets or exceeds the order amount,
that order has been "filled", and I lock (enabled = false) the subform from
any more disbursements.

My subform code keps track of the amounts disbursed as records are added,
and alerts the user that the disbursement is "incomplete", "complete", or
"over-disbursed" and... when applicable, moves the focus out of the subform,
and locks it. That all works fine.

Problem...
However, as the user browses between Main form records, I need to also
need to check this "status" and lock/unlock the subform accordingly. Some
orders are filled... some are not.
Using the Main form OnCurrent event... when I ask what the value of
TotalDisbursed is, there never seems to be a value. Seems as though the
Subform and Main haven't "connected" at that time. When the form comes up,
all the values are correct... but there appears to be no TotalDisbursed
value at OnCurrent time.

OnCurrent...
If Me![frmSubform].Form![TotalDisbursed] >= Me.OrderAmt Then...
'locking code
Else
'unlocking code
End If

Can anyone give me suggestions as to what's going on here, and how I
might be able to perform this OnCurrent checking?
Thanks in advance,
Al Camp
 
Well, I'm going to attempt to answer my own question. I found a
solution, and would like to run it by the NG.
I am now using the Subform OnCurrent to make the decision whether to disable
the subform or not.... as opposed to using the Main form for that purpose.
When the Subform is Current, it knows the value of it's own calculated
footer field ([TotalDisbursed]).
It also can find the value on the Main form that I need to compare it
to...([OrderedLength])
At that time I can move the focus to the Main form, and disable the
Subform, or enable the Subform.

I can only gather that the Subform must be Current before the Main, and
can determine it's own calculated values as well as "bound" values on the
Main form.
It doesn't appear that it works the other way around. The Main form
OnCurrent just doesn't "see" the subform calculation value.

Any feedback would be appreciated... and thanks.

Al Campagna
Candia, NH
 
Back
Top