Auto calc in form OR a manual entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field in my form (bound to a tbl) that needs to =[UnitPrice]*2 or a
manual entry. I got the calculation ok - but it won't let me enter data
besides the calculation. What am I missing???
 
SD,

I am not 100% sure I understand what you want to do. But a textbox
control on a form can either be bound or unbound. If is is bound, the
data shown is the data in the corresponding field in the underlying
table, and any editing of the data in the control we be reflected in a
change in the data stored in the table field. If it is unbound, then it
can have an expression in its Control Source property, or the Control
Source property can be left blank. If it is left balnk, data can be
entered into the control, but this data is not related to stored data in
your database. If there is an expression, the data shown in the control
is the result of the expression, which I guess is what you've got with
your =[UnitPrice]*2. In this case, you can't enter/edit the data shown
in this control. In other words, you can't mix and match the
functionality between these differerent "types" of textbox structure.
 
OK- I see. But Can I change the default value in my table to[unitPrice]*2? I
tried but it doesn't recognize the field. What is the best way to handle this
since it is bound to a table?

Steve Schapel said:
SD,

I am not 100% sure I understand what you want to do. But a textbox
control on a form can either be bound or unbound. If is is bound, the
data shown is the data in the corresponding field in the underlying
table, and any editing of the data in the control we be reflected in a
change in the data stored in the table field. If it is unbound, then it
can have an expression in its Control Source property, or the Control
Source property can be left blank. If it is left balnk, data can be
entered into the control, but this data is not related to stored data in
your database. If there is an expression, the data shown in the control
is the result of the expression, which I guess is what you've got with
your =[UnitPrice]*2. In this case, you can't enter/edit the data shown
in this control. In other words, you can't mix and match the
functionality between these differerent "types" of textbox structure.

--
Steve Schapel, Microsoft Access MVP

I have a field in my form (bound to a tbl) that needs to =[UnitPrice]*2 or a
manual entry. I got the calculation ok - but it won't let me enter data
besides the calculation. What am I missing???
 
SD,

No, you can't do calculations in a table. This is one of the basic
principles of database design, that you generally shouldn't store
derived/calculated data in a table anyway. If you have a field in your
table that is supposed to show the value of [unitprice]*2 then you
should remove this field from the table. Whenever you need this value
for your purposes on form or report, you should use a calculation "on
the fly", either in the query that the form or report is based on, or
via an expression in a calculated control on the form or report itself.
If there is some reason why this approach won't meet your needs, let
us know why, with examples, and someone will be able to help further.
 
In the form you are using for your data entry, you could set the default
value for this field to be [UnitPrice]*2. Then, you can override it before
saving your record, if you need to.

Normally, you would not save calculations that can be later generated, but
it sounds like the calculation might just be a starting point for this field
and something that is often overridden.

Rick B
 
Back
Top