Format question?

A

a24t42

I need some help with formatting a numeric field. I need it to be 3
characters long with one decimal place. Right now, when I enter 45 it
shows 45.0 and when I enter 123 it shows 123.0. What I want is it to
show 4.5 or 12.3.

Any help would be most appreciated.
 
D

Douglas J. Steele

It's not clear to me what your problem is.

Is it that it's displaying "n.0" instead of "n.5 or n.3"? If so, what's the
Field Size been defined for the field(s) in question? When you set a field
to Numeric, the default Field Size is Long Integer, which doesn't support
decimal points. You need to choose a different Field Size, like Single or
Double.
 
G

Guest

If you always enter an integer, but you want both the value shown in the
control and the actual underlying value to be the number with one decimal
place then just divide the value by 10 in the control's AfterUpdate event
procedure:

[MyNumber] = [MyNumber]/10

If you want the underlying value to be the integer as entered, but the
control to show the one decimal place then you could use a bound control for
entering the data and an unbound one to show its value divided by 10. You
could use code to juggle the Visible properties of the two controls to show
the bound one when you need to enter data and the unbound one to show its
scaled down value. Or you can just use just an unbound control and assign
the value entered divided by 10 to the control and as entered to the
underlying field in code. You'd need to assign the value to the control in
the form's Current event procedure too. This latter approach would only work
in single form view however.

I do wonder why you need to do this, however. Why not just enter the number
as a decimal in the first place?

Ken Sheridan
Stafford, England
 
6

'69 Camaro

Hi.
Right now, when I enter 45 it
shows 45.0 and when I enter 123 it shows 123.0.

That's because 45 _is_ 45.0 in decimal, and 123 _is_ 123.0 in decimal.
What I want is it to
show 4.5 or 12.3.

Even if both the decimal key and period key are broken on all of the
keyboards used for this application you're building, this is a not a good
idea. Years ago, one of the United States (I think it was Indiana) passed a
law making one inch equal to three centimeters, and it wasn't until they
realized how impractical it was to redefine standards that they finally
rescinded their law. Likewise, making 45 = 4.5 and 123 = 12.3 is going to
cause you inordinate amounts of needless work, not to mention the ridicule
when others hear about it, as that State's lawmakers received.

Tell the users to use the decimal key. That's what it's for.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top