Set the formula (Field value) as the ControlSource of your TextBox by code.
For example, in one of my databases (for PVC pipe manufacturer) where the
formulation consists of the main component PVC resin and additives (filler,
UV resistant additive, color additive, lubricants, etc ...) and the
quantities of the additives are measured "parts per hundred (parts) of PVC
resin" (PHR), e.g. UV additive 1.5 PHR means for 100 kg of resin, 1.5 kg of
UV resistant additive is required.
Another factor is that each factory may have a number of different mixing
bowls with different capacities. Not only that, some factories prefer to
start with, says 350 kg of resin (our notation "350R") end up with the
resultant mix higher than 350 kg due to the additives. Some other factories
prefer to end up with a fixed amount of of resultant mix, e.g. total 350 kg
at the end and need the database to work out how much resin + how much of
each additive to use to end up with 350 kg total (our notation "350T").
Basically, I end up with the following "BatchFactor" choices (requested by
the users):
250R
300R
350T
350R
....
500T
500R
I use a Table "tlkpBatchFactor" to store the formulae to work out the weight
of each component depending on the PHR of the component (resin amount is
obviously 100 PHR). For example:
For 350R: "=[txtPHR]*3.5"
For 350T:
"=Iif([RecordsetClone].[RecordCount]>0,[txtPHR]/Sum([PHR])*350, 0)"
[txtPHR] is bound to the Field "PHR" in the Table tblFormulationDetail
(1-to-M from tblFormulation to tblFormulationDetail).
The main Form is bound to the tblFormulation, the Subform (in CtsFormView)
is bound to the tblFormulationDetail. In the FormHeader of the Subform, I
have an unbound ComboBox with 3 Columns: BatchFactorID, BatchFactor,
BatchFactorComponentFormula (above). When the user select a Factor, I use
the ComboBox_AfterUpdate Event to set the ControlSource of the TextBox for
the ComponetRequiredWeight like:
Me.txtComponentRequiredWeight.ControlSource = Me.cboBatchFactor.Column(2)
(Hope you understand this long long post.)
--
HTH
Van T. Dinh
MVP (Access)
RosuAndreiMihai said:
No, no, no
I was trying to tell something else!
In a table I have a text cell with a function in it like DSum("X","Y")
In a form I have a control that is taking data from that cell, but I
cannot
see the result of the formula, but the formula itself! Could you help me?
"Jerry Whittle" a scris: