Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prevent access removing preceding zeros from a number

Status
Not open for further replies.

bodmin

Technical User
Apr 1, 2004
98
GB
Hi hope someone can help,

I have got a number input from a form that should match the number of a printed stationary, these numbers can have preceding zero digits and I cant stop access from removing these preceding digits when it stores the value in the database.

Is there an easy way to stop access from modifying the value or am I going to have to take as a string and do some work to use the value in calculations?

is there a way to set a value mask that will allow preceding zero's in a number?
 
It doesn't really matter how Access stores the data - design is easier if you keep the data and presentation layers separate. You can use FORMAT(x, "00000") to display x with leading zeroes but use the numeric value of x for calculations.

Geoff Franklin
 
You will have to enter as a string, unless all numbers have the same amount of preceding zeroes. Geoff's idea will work if they have all the same number of preceeding zeros, but not if you have:
0001245
0024527
0345542

Enter as a string and then in a query make a calculated field to convert to a long.
lngStationaryNumber:CLNG(tblName.strStationaryNumber)
 
MajP, I must disagree:[tt]
Format(1245,"0000000") 0001245
Format(24527,"0000000") 0024527[/tt]

For me, the rule is: if you do math with a field then it should be stored as numeric.
 
Yeah, that was a bad example. What I meant was the case were you have.
0012
00002345
0236
0000000345987
I have no idea what the real data is like. I was thinking more on the line where you are concerned with precision of measurement. In that case
123.90
123.900
123.90000
Are all very different numbers.
I would either have to store as a string or store the number of significant digits in another field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top