Red_Star20 said:
Another thing,
Do u by any chance know how to record a calculated control's content
into a table? To my knowledge calculated controls are unbound by
nature, so it would not be possible, but I am sure there is another
way.
Let's say I have two textboxes, textbox 1 and textbox 2 both
containing number.
I also want a third textbox in which the product of the two numbers
show up when clicking a command button. I can write in the 3rd text
box's control source the following: =[textbox1]*[textbox2] and this
does the multiplication, but I need to get a command button involved
and make the 3rd textbox's content stored in my table...
Any clue on this?
You could clear the ControlSource you have now and in the AfterUpdate event
of BOTH textbox1 and textbox2 have code...
Me.textbox3 = Me.textbox1 * Me.textbox2
BUT **** This is a BAD IDEA. If either field is ever changed by some method
other than your form you will have bad data and no way of knowing which
field is incorrect. That is (one of the reasons) why storing calculated
data is simply NOT done except in very rare cases.
What you SHOULD do is create a SELECT query based on your table (from which
you have removed this field) and in the query you perform the calculation
for field1* field2. Then you simply substitute that query every place you
are now using the table. The value for field3 will be there, it will
automatically update whenever you change either of the other field values,
and it will always be correct.
If you were doing this in Excel would you put an expression into the third
column to do a live calculation or would you create a macro that looped
through all rows in the sheet multiplying the value in columnA by the value
in columnB and place the result into columnC? The latter sounds pretty
ridiculous doesn't it? It is the equivelant of storing the result of a
calculation in a database table.