SubForm and Expression

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

I have made a from called frmTransaction_New to be a
subform on another for called frmInvoice_New. ON the
frmTransaction_New, I have this feild that totals
UnitsIn*Quantity and show the value on the form. I have
also another feild named GrandTotal to save the
calculated value in the table for that specific item. In
the onClick property of this GrandTotal I have placed a
Macro to set the value of this feild. The expression work
on the frmTransaction-New, but as the subform, it wont, I
get an error message saying the form is not open or may
not exist.

here is the expression:

[Forms]![frmTransaction_New]![GrandTotal]
([Forms]![frmTransaction_New]![Quantity]*[Forms]!
[frmTransaction_New]![UnitCost]+[Forms]!
[frmTransaction_New]![MiscCost])

I can't figure it out of why? It is looking for the
actual frmTransaction to be opened, and if it is open,
the Macro works. Is there a workaround? or a solution to
this current issue?

Thank you in advance for your help.

Regards,

Mike
 
I have made a from called frmTransaction_New to be a
subform on another for called frmInvoice_New. ON the
frmTransaction_New, I have this feild that totals
UnitsIn*Quantity and show the value on the form. I have
also another feild named GrandTotal to save the
calculated value in the table for that specific item. In
the onClick property of this GrandTotal I have placed a
Macro to set the value of this feild. The expression work
on the frmTransaction-New, but as the subform, it wont, I
get an error message saying the form is not open or may
not exist.

When referencing fields on subforms, use the following syntax:

Forms!MainFormName.SubformControlName.Form!FieldName
.... or ...
Me.SubformControlName.Form!FieldName

"MainFormName" being the name of the main form, "SubformControlName" being the
name of the subform *control* on the main form (not the name of the subform,
although they may both share the same name), "Form" being a property of the
subform *control* and "FieldName" being the name of the field that you want to
reference.

See http://www.mvps.org/access/forms/frm0031.htm for a complete rundown.
 
Bruce,

I'm a little confused here.

By the Main Form, do you mean the form that I have placed
a subform on or the name of the SubFor before it became a
subform?
And , by feild Name, All the Control Names on the subform
are the same as the Form itself since the form was
dragged onto another form to be a subform.

Thx,

Mike


-----Original Message-----

When referencing fields on subforms, use the following syntax:

Forms!MainFormName.SubformControlName.Form!FieldName
.... or ...
Me.SubformControlName.Form!FieldName

"MainFormName" being the name of the main
form, "SubformControlName" being the
 
I'm a little confused here.
By the Main Form, do you mean the form that I have placed
a subform on or the name of the SubFor before it became a
subform?

The form on which you have placed a subform on.
And , by feild Name, All the Control Names on the subform
are the same as the Form itself since the form was
dragged onto another form to be a subform.

That's fine - in this case, I would presume that the control names are the same
as the field names. The field/control names don't change when a form becomes a
subform.
 
Back
Top