A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

calculations in form



 
 
Thread Tools Display Modes
  #1  
Old December 20th, 2006, 04:45 PM posted to microsoft.public.access.forms
rs30
external usenet poster
 
Posts: 1
Default 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  
Old December 20th, 2006, 06:40 PM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.