# How convert inches to feet and inches

I have two field on a form.  The first one is txtTotal Inches .  When the user enters a number in this field, for example... 50, I want the 2nd field to populate with 4' - 2"

How can I do this?
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

For inches to feet you would take the field and divide by 12 that would make the second field come out as 4.17 if rounded. This is 4 feet and .17 feet. If you want to change the display to somthing else that would take another formula.

Question when you say form do you mean in access as the topic suggests?

If it is access you can code it with VB and find a converter code using google. There are plenty of sites to help with writing this code as well but I would find a pre-built converter and just place it where you need it in the code.
0
Infotrakker SoftwareCommented:
You can try this:

Me.YourTextbox = CInt(Me.txtTotalInches/12) & "' " & Me.txtTotalInches Mod 12 & """"
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Director, Practice Manager and Computing ConsultantCommented:
1. Click on the Textbox.
2. Go into the Property Sheet (click F4 if it is not available).
3. Click inside "On Exit" and click the "..." button which is now visible.
4. Select "Code Builder" in the "Choose Builder" dialog.
5. The VBA window will open with:
``````Private Sub txtTotal_Inches_Exit(Cancel As Integer)

End Sub
``````
6. Insert in the empty line in the middle:
``````[lblTotal].Caption = Int(txtTotal_Inches.Value / 12) & "' - " & txtTotal_Inches.Value Mod 12 & Chr(34)
``````
Where "lblTotal" is your second field.
0
Author Commented:
Perfect!!!  Thank you.
0
Author Commented:
Whoops.  I may have accepted to quickly.  I have this code in the on current event of the form:

Me.txtStdWidthInFeetAndInches = CInt(Me.txtStandardWidthInInches / 12) & "' " & Me.txtStandardWidthInInches Mod 12 & """"

But when I go to a new record I get an Invalid use of null error.
0
Infotrakker SoftwareCommented:
I'd check for a value in your textbox first:

If Nz(Me.txtStandardWidthInInches,0) <> 0 Then
Me.txtStdWidthInFeetAndInches = CInt(Me.txtStandardWidthInInches / 12) & "' " & Me.txtStandardWidthInInches Mod 12 & """"
End Id
0
Author Commented:
Yep.  Thanks again.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.