If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
calculations in form
I have a form for users to enter data. I would like users to be able to
enter data on height and weight in either (cm) or (in) and (kg) or (lbs) but only store the data in my table in metric. Tips? |
#2
|
|||
|
|||
calculations in form
On Wed, 20 Dec 2006 08:45:02 -0800, rs30
wrote: I have a form for users to enter data. I would like users to be able to enter data on height and weight in either (cm) or (in) and (kg) or (lbs) but only store the data in my table in metric. Tips? One way would be to use three controls for each such field: an unbound textbox for the user entry; an Option Group control with the units (say Kilograms, Pounds, Stones, as 1, 2, 3), and a textbox (which might be invisible) bound to the metric table field. You could have code in the AfterUpdate event of the unbound data entry textbox to read the unit control and make the appropriate calculation, e.g. Private Sub txtEnterWeight_AfterUpdate() Select Case Me.optUnits Case 1 ' kilograms, just pass the value Me.txtWeight = Me.txtEnterWeight Case 2 ' pounds Me.txtWeight = Me.txtEnterWeight * 2.2046 Case 3 ' stones Me.txtWeight = Me.txtEnterWeight * 0.15747 End Select End Sub You'll want code going the other way (filling the txtEnterWeight textbox by converting from kilograms to the other unit) in *both* the form's Current event and the option group's AfterUpdate event. John W. Vinson[MVP] |
Thread Tools | |
Display Modes | |
|
|