Calculation question

belsha

Registered User.
Local time
Today, 16:31
Joined
Jul 5, 2002
Messages
115
I have a bound text box where the user is supposed to enter weight in kg. I would like to have an unbound textbox where they could enter weight in pounds & ounces (these are infants) and have it show the conversion for kg, so that could be entered correctly. First, how could I get the box to accept BOTH pounds and ounces (eg. 4 lbs 2 oz) for this calculation? kg = weight/2.2 is the formula for conversion, if this was just lbs I could do it. Best way to handle this? Thanks!
 
Hmm...maybe someone has a clever way of handling the numbers when entered into a single text box, but I think it's far easier to handle them separately in two boxes.

Even if you direct people to enter the digits a specific way, you'll get variations (and then frustration!). Inevitably, someone will enter "4 pds 2 oc", or "4.5 lbs" (by the way, those are very small infants!). If you want to still go that route, you'll have to work with the string functions to extract the numbers you want. You should look up help information on Mid, Left, Right, and possibly the Instr function.
 
Calculation

Figured I would have to use 2 boxes but was hoping otherwise. Yes, these are NICU (Intensive care infants, many premies) so that is why the ounces are so critical to take into account. Then the problem of 4 lbs 5 ounces does not equal 4.5 lbs (which is 4 lbs 8 oz) becomes critical. Any suggestions are appreciated.
 
Robert Dunstan's converter works well. The only things I'd change are placing some code into Exit event of the text boxes to double-check for numeric entries (users type all sorts of things) and to automatically do the calculation without having to press the "Convert" button, but those are minor quibbles.

Some not-so-minor stuff though, since the equations use the Round function, this will only work in Access 2000+, and I'm not sure how precise belsha needs to be with the figures. Also, aren't there 16 ounces to a pound? This equation:
Me.txtPounds.Value = Round((Me.txtLbs + (Me.txtOz / 14)), 2)
suggests that there are 14.
 
Hi dcx

This is just a simple example but your quite right to point out that with a bit of extra coding the calculation can be automated without pressing the convert button. Also the calculation would need to test for a null in both fields otherwise it won't work.

I just wanted to prove to myself that I could still work out the maths :D

Also I always thought there were 14 ounces to a pound but may be I'm wrong.

Rob
 
Over here in the States, there are 16 ounces to a pound, but those rules might not apply in the Delta Quadrant. :D
 
Calculation

Correct, 16 ounces per pound. I will try the converter, and check to see how much of a round on the number is tolerable.
 
The delta quadrant doesn't have rules...only The Borg!

Oh well maybe I'll engage my cloaking device and speed off at warp 9 ;)
 

Users who are viewing this thread

Back
Top Bottom