Reference to subform control from another subform control

J

Jaybird

The syntax of these subform control references always gets me...

I would like the value of txtCreditMemo on subform ChildsbfInvoice to be
zero if the sum of txtLINTOTL on subform qryLINPLAT is less than zero. I've
tried all kinds of things but my code is currently this:

Private Sub Form_Current()
Dim MyVariable As Variant

MyVariable = Sum(Me.Parent.qryLINPLAT.Form.txtLineTotal)
If MyVariable < 0 Then Me.txtCreditMemo = 0
If MyVariable >= 0 Then Me.txtCreditMemo = 1


End Sub
 
J

Jaybird

When I put this code into the OnCurrent event of the main form, it seems to
work...

Private Sub Form_Current()
Dim MyVariable As Variant
Me.Recalc
MyVariable = Nz(Me.txtLineItemsSubTotal, 0)
If MyVariable < 0 Then Forms!frmInvoice!ChildsbfInvoice!CreditMemo = 0
If MyVariable >= 0 Then Forms!frmInvoice!ChildsbfInvoice!CreditMemo = 1
End Sub

I guess that the loading order of the information to the subforms was not
allowing my references to be valid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top