Leading zero's

  • Thread starter CCTD via AccessMonster.com
  • Start date
C

CCTD via AccessMonster.com

I have 2 fields in access - I need the first to update with 6 digits 000009 ,
000546, or 001244 - the send with 3 digits 075, 100, 050

I only want to key in the digits (no zero's) 546 1244 and 75 100 50
how can i get access to add the leading zero's - and the correct number of
leading zero's (notice it can be as few as 1 and as many as 5)
 
J

John W. Vinson

I have 2 fields in access - I need the first to update with 6 digits 000009 ,
000546, or 001244 - the send with 3 digits 075, 100, 050

I only want to key in the digits (no zero's) 546 1244 and 75 100 50
how can i get access to add the leading zero's - and the correct number of
leading zero's (notice it can be as few as 1 and as many as 5)

What's the datatype of the field - Number or Text? If it's number, be aware
that 9, 009 and 0000009 are *the same number*; you can set the Format property
of a textbox to "000000" to display all numbers with leading zeros, but
they're stored identically.

If it's Text, you can use a Form to enter the data and put code in the
textbox's AfterUpdate event:

Private Sub controlname_AfterUpdate()
Me.controlname = Right("0000000" & Me.controlname, 6)
End Sub

to append zeros to the beginning of whatever the user types, and trim that
string to 6.

John W. Vinson [MVP]
 
G

Guest

With the assumption that it is a text field, I use a format feature in the
afterupdate event to add the leading zeros.
me.fieldname = format(me.fieldname, "000000")
this would make any entry entered with leading zero's

SteveD
 

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

Similar Threads

AS400 Leading Zero's 3
adding leading zeros 3
Update/Append Queries 3
Insert leading zero's 2
Striping Leading Zero's 5
Import data 1
Leading zero's 4
Formatting numbers with leading and trailing zero's 7

Top