Solved

How convert inches to feet and inches

Posted on 2014-11-21
7
158 Views
Last Modified: 2014-11-21
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?
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:Aaron
ID: 40457279
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
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40457287
You can try this:

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

Expert Comment

by:Phillip Burton
ID: 40457291
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

Open in new window

6. Insert in the empty line in the middle:
[lblTotal].Caption = Int(txtTotal_Inches.Value / 12) & "' - " & txtTotal_Inches.Value Mod 12 & Chr(34)

Open in new window

Where "lblTotal" is your second field.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:SteveL13
ID: 40457328
Perfect!!!  Thank you.
0
 

Author Comment

by:SteveL13
ID: 40457584
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
 
LVL 84
ID: 40457597
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 Comment

by:SteveL13
ID: 40457681
Yep.  Thanks again.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question