update textboxes with a formula without using the AfterUpdate_event for each textbox

Richard1980

Registered User.
Local time
Today, 17:47
Joined
Aug 13, 2012
Messages
72
Hello guys,
I have a form with 7 types of weights (7 textbox rows) showing 7 weights in kgs and the others in lbs.
When the user update any weight-kgs textbox, the opposite weight-lbs textbox will be updated automatically, and viceversa.
Now, I'd like a fast way to code this action without writing the AfterUpdate_event for every textbox (they're 14).
I have already setup textbox tags differently with "WeightKGS" and "WeightLBS", thinking about using "for each ... next" statement, but I have some problems to resolve what I want.
Any suggestion about this task?
Thanks a lot.
Bye.
 
For starters, storing both lbs and kgs is unnecessary since one can easily be derived from the other. You should also probably not be storing 7 weights. When you have a 1-many relationship, the many-side data should be stored in a separate table.

If you are allowing updates in both lbs and kgs, you need the calculation in the AfterUpdate event of EACH field so that would be 14 places. You could do it all in the BeforeUpdate event of the form but it would be much more complicated because you would have to determine which fields changed before doing each individual calculation.

I have a form that has a similar requirement. It collects income and expense amounts and they can enter them either as monthly or annual amounts. I keep one value in the database as a monthly amount. On the form, they have one value field and one combo that has monthly/yearly as options. The default is monthly since that is the most common type. In the AfterUpdate event, I divide by 12 if they enter a yearly number.
 
>>7 types of weights<<

Of course I’m guessing here but what happens if you ever need 8 or 9 or…?
You would not want to keep changing the Form so they might as well be in a subform.

There is a small A2003 demo attached which brings all weights forward when a new one-side record is created. It saves having to re-type the weight names every time.

Maybe that would be a better solution???

Chris.
 

Attachments

>>7 types of weights<<

Of course I’m guessing here but what happens if you ever need 8 or 9 or…?
You would not want to keep changing the Form so they might as well be in a subform.
Ah ok, reading now your reply, I know that You (Chris) & Pat (probably), did not understand well my first post. When I speak about 7 kind of weights, I refer to this: I have a form where for every aircraft saved into the database the user has to load weights for different configurations. Every aircraft has a max weight for a specific situation (MTW stands for Maximum Taxi Weight, MTOW stands for Maximum Take-off weight, MLW stands for Maximum Landing weight and so on). As said, I will have only 7 kind of weights, no more.
All those textboxes will be bound to the table where I need to store weight either in kgs and in lbs, and the user can choose, by an option button, wheter fill the form in lbs or in kgs.
Just to be clearer. :)
Ok, I will write the code AfterEvent for every textbox.
Bye. Thanks.
 

Users who are viewing this thread

Back
Top Bottom