Solved

How convert inches to feet and inches

Posted on 2014-11-21
7
142 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
7 Comments
 
LVL 5

Expert Comment

by:Aaron
Comment Utility
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
Comment Utility
You can try this:

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

Expert Comment

by:Phillip Burton
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Closing Comment

by:SteveL13
Comment Utility
Perfect!!!  Thank you.
0
 

Author Comment

by:SteveL13
Comment Utility
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
Comment Utility
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
Comment Utility
Yep.  Thanks again.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now