form/ subform calculation

  • Thread starter Thread starter JennKriv
  • Start date Start date
J

JennKriv

I am trying to do a multiplication expression but it is not working right.
I want a value from my main form to multiply from my subform. the end value
is also in my subform.
The equation I came up with is
=[F-Cutlist]![QTY]*[F-CutlistDetail]![PER]
I originally got a value but when the qy was increased the per did not
increase, and now I am getting no amount.
Any Ideas what I did wrong?
 
When you want to reference a control on a subform you use the following
syntax;

MainFormName!SubformControlName.Form!ControlName

So in your case it would probably be;

=[F-Cutlist]![QTY]*[F-Cutlist]![F-CutlistDetail].Form![PER]

I say probably because you are actually referring to the subform control.
The name of the subform control is usually, but not necessarily, the same
as the name of the subform itself.

_________

Sean Bailey
 
That didn't seem to work for me
I don't know if it helps if I give you the form names and boxes associated
with the calculation....

Main Form Title: F-Cutlist
Main Form Text Box: QTY
SubForm Title: F-CutlistDetail
SubForm Text Box: PER
And I want the equation placed in the PCS box under F-CutlistDetail
(subForm)


Beetle said:
When you want to reference a control on a subform you use the following
syntax;

MainFormName!SubformControlName.Form!ControlName

So in your case it would probably be;

=[F-Cutlist]![QTY]*[F-Cutlist]![F-CutlistDetail].Form![PER]

I say probably because you are actually referring to the subform control.
The name of the subform control is usually, but not necessarily, the same
as the name of the subform itself.

_________

Sean Bailey


JennKriv said:
I am trying to do a multiplication expression but it is not working right.
I want a value from my main form to multiply from my subform. the end value
is also in my subform.
The equation I came up with is
=[F-Cutlist]![QTY]*[F-CutlistDetail]![PER]
I originally got a value but when the qy was increased the per did not
increase, and now I am getting no amount.
Any Ideas what I did wrong?
 
Sorry, my bad. The syntax I posted was incorrect because you also have to
reference the Forms collection. Also in your case you can probably just
use a direct reference to the [PER] control on your subform since [PCS]
is on the same subform. Assuming that [PCS] is an unbound textbox,
try this in it's control source;

=[Forms]![F-Cutlist]![QTY]*[PER]

see if that works.

--
_________

Sean Bailey


JennKriv said:
That didn't seem to work for me
I don't know if it helps if I give you the form names and boxes associated
with the calculation....

Main Form Title: F-Cutlist
Main Form Text Box: QTY
SubForm Title: F-CutlistDetail
SubForm Text Box: PER
And I want the equation placed in the PCS box under F-CutlistDetail
(subForm)


Beetle said:
When you want to reference a control on a subform you use the following
syntax;

MainFormName!SubformControlName.Form!ControlName

So in your case it would probably be;

=[F-Cutlist]![QTY]*[F-Cutlist]![F-CutlistDetail].Form![PER]

I say probably because you are actually referring to the subform control.
The name of the subform control is usually, but not necessarily, the same
as the name of the subform itself.

_________

Sean Bailey


JennKriv said:
I am trying to do a multiplication expression but it is not working right.
I want a value from my main form to multiply from my subform. the end value
is also in my subform.
The equation I came up with is
=[F-Cutlist]![QTY]*[F-CutlistDetail]![PER]
I originally got a value but when the qy was increased the per did not
increase, and now I am getting no amount.
Any Ideas what I did wrong?
 
Nope, still won't work. I get nothing in the [PCS] box. I am putting the
equation under the default value which I believe is correct. [PCS] is bound,
it is in the [CutlistDetail] table because it needs to be shown when the
report is created.


Beetle said:
Sorry, my bad. The syntax I posted was incorrect because you also have to
reference the Forms collection. Also in your case you can probably just
use a direct reference to the [PER] control on your subform since [PCS]
is on the same subform. Assuming that [PCS] is an unbound textbox,
try this in it's control source;

=[Forms]![F-Cutlist]![QTY]*[PER]

see if that works.

--
_________

Sean Bailey


JennKriv said:
That didn't seem to work for me
I don't know if it helps if I give you the form names and boxes associated
with the calculation....

Main Form Title: F-Cutlist
Main Form Text Box: QTY
SubForm Title: F-CutlistDetail
SubForm Text Box: PER
And I want the equation placed in the PCS box under F-CutlistDetail
(subForm)


Beetle said:
When you want to reference a control on a subform you use the following
syntax;

MainFormName!SubformControlName.Form!ControlName

So in your case it would probably be;

=[F-Cutlist]![QTY]*[F-Cutlist]![F-CutlistDetail].Form![PER]

I say probably because you are actually referring to the subform control.
The name of the subform control is usually, but not necessarily, the same
as the name of the subform itself.

_________

Sean Bailey


:

I am trying to do a multiplication expression but it is not working right.
I want a value from my main form to multiply from my subform. the end value
is also in my subform.
The equation I came up with is
=[F-Cutlist]![QTY]*[F-CutlistDetail]![PER]
I originally got a value but when the qy was increased the per did not
increase, and now I am getting no amount.
Any Ideas what I did wrong?
 
The [PCS] control needs to be unbound and the calculation should be in
it's control source. In most cases, you should not store a calculated result
in a table. A snip from your original post -
I originally got a value but when the qy was increased the per did not
increase,

is one of the reasons why you don't store calculated values in a table. If one
of the calculations underlying fields gets changed, the result stays the same,
so what started out as

2 + 2 = 4

now says

3 + 2 = 4

A better option may be to create a query with all the relevant fields from
your
F-CutlistDetail table, then add a calculated field to the *query* using, for
example, DLookup to get the QTY value from the F-Cutlist table and
multyply it by [PER]. Then use this query as the recordsource of your
F-CutlistDetail subform, and use the calculated field in the query as the
control source for [PCS]. You would also probably want to add some code
in the after update event of the [QTY] control, and the current event of your
main form, to requery the subform when the value changes, or you move to
a different record. Likewise, your report would use the query as it's
recordsource.

Personally, I almost always use queries as the recordsource for forms/reports.
Queries make it easier to sort fields the way you want, perform
calculations, etc.
--
_________

Sean Bailey


JennKriv said:
Nope, still won't work. I get nothing in the [PCS] box. I am putting the
equation under the default value which I believe is correct. [PCS] is bound,
it is in the [CutlistDetail] table because it needs to be shown when the
report is created.


Beetle said:
Sorry, my bad. The syntax I posted was incorrect because you also have to
reference the Forms collection. Also in your case you can probably just
use a direct reference to the [PER] control on your subform since [PCS]
is on the same subform. Assuming that [PCS] is an unbound textbox,
try this in it's control source;

=[Forms]![F-Cutlist]![QTY]*[PER]

see if that works.

--
_________

Sean Bailey


JennKriv said:
That didn't seem to work for me
I don't know if it helps if I give you the form names and boxes associated
with the calculation....

Main Form Title: F-Cutlist
Main Form Text Box: QTY
SubForm Title: F-CutlistDetail
SubForm Text Box: PER
And I want the equation placed in the PCS box under F-CutlistDetail
(subForm)


:

When you want to reference a control on a subform you use the following
syntax;

MainFormName!SubformControlName.Form!ControlName

So in your case it would probably be;

=[F-Cutlist]![QTY]*[F-Cutlist]![F-CutlistDetail].Form![PER]

I say probably because you are actually referring to the subform control.
The name of the subform control is usually, but not necessarily, the same
as the name of the subform itself.

_________

Sean Bailey


:

I am trying to do a multiplication expression but it is not working right.
I want a value from my main form to multiply from my subform. the end value
is also in my subform.
The equation I came up with is
=[F-Cutlist]![QTY]*[F-CutlistDetail]![PER]
I originally got a value but when the qy was increased the per did not
increase, and now I am getting no amount.
Any Ideas what I did wrong?
 
Back
Top