Repost: Using a sub-form field in a calculation

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I have an unbounded form with a dropdown box for states.
Based on the value selected in that dropdown box, I have a
value selected from a query that is shown in a sub-form.
Now I want to do some calculations on that returned value
but if I try to use that field I get #Name? as calculated
value.

In the underlining query that creates my subform I have
the selection criteria of [Forms]![frmState]![State
Name]. That query results in only one row being
returned. I want to use that row result to do a
calculation in my main form. I put the query in a subform
because I'm going to need to do this same thing with
multiple tables (not all of which are based on state) and
I thought that I could grab the number the same way I did
for the query. But when I refer to the field (=[Forms]!
[frmTrend]![Text5]) I get the #Name? error. I've also
tried using the query field as my control but that doesn't
work either. Any help would be appreciated.
 
looks like your problem is the field reference. to do a calculation in the
main form, based on a value in the subform, you have to refer to the subform
as an object of the main form.
first, get the subform's *control* name. in the main form design view, click
*once* on the subform to select it. open the Properties box (if not already
open) and look at the Name property. for the example below, i'll call the
subform control Child1.
in the main form's calculated field, change the reference to

= [Child1].Form![Text5]

if you use the expression builder, it should give you the proper syntax
automatically. (that's what i did, to create this example.)

hth
 
Thank you! Thank you! Thank you, Tina! You are the most
intellegent and beautiful woman in the world!
-----Original Message-----
looks like your problem is the field reference. to do a calculation in the
main form, based on a value in the subform, you have to refer to the subform
as an object of the main form.
first, get the subform's *control* name. in the main form design view, click
*once* on the subform to select it. open the Properties box (if not already
open) and look at the Name property. for the example below, i'll call the
subform control Child1.
in the main form's calculated field, change the reference to

= [Child1].Form![Text5]

if you use the expression builder, it should give you the proper syntax
automatically. (that's what i did, to create this example.)

hth


I have an unbounded form with a dropdown box for states.
Based on the value selected in that dropdown box, I have a
value selected from a query that is shown in a sub-form.
Now I want to do some calculations on that returned value
but if I try to use that field I get #Name? as calculated
value.

In the underlining query that creates my subform I have
the selection criteria of [Forms]![frmState]![State
Name]. That query results in only one row being
returned. I want to use that row result to do a
calculation in my main form. I put the query in a subform
because I'm going to need to do this same thing with
multiple tables (not all of which are based on state) and
I thought that I could grab the number the same way I did
for the query. But when I refer to the field (=[Forms]!
[frmTrend]![Text5]) I get the #Name? error. I've also
tried using the query field as my control but that doesn't
work either. Any help would be appreciated.


.
 
you're welcome! <big smile>

Bob said:
Thank you! Thank you! Thank you, Tina! You are the most
intellegent and beautiful woman in the world!
-----Original Message-----
looks like your problem is the field reference. to do a calculation in the
main form, based on a value in the subform, you have to refer to the subform
as an object of the main form.
first, get the subform's *control* name. in the main form design view, click
*once* on the subform to select it. open the Properties box (if not already
open) and look at the Name property. for the example below, i'll call the
subform control Child1.
in the main form's calculated field, change the reference to

= [Child1].Form![Text5]

if you use the expression builder, it should give you the proper syntax
automatically. (that's what i did, to create this example.)

hth


I have an unbounded form with a dropdown box for states.
Based on the value selected in that dropdown box, I have a
value selected from a query that is shown in a sub-form.
Now I want to do some calculations on that returned value
but if I try to use that field I get #Name? as calculated
value.

In the underlining query that creates my subform I have
the selection criteria of [Forms]![frmState]![State
Name]. That query results in only one row being
returned. I want to use that row result to do a
calculation in my main form. I put the query in a subform
because I'm going to need to do this same thing with
multiple tables (not all of which are based on state) and
I thought that I could grab the number the same way I did
for the query. But when I refer to the field (=[Forms]!
[frmTrend]![Text5]) I get the #Name? error. I've also
tried using the query field as my control but that doesn't
work either. Any help would be appreciated.


.
 
Back
Top