By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,572 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

Number entry (leading zeros)

P: n/a
LFM
I am sure there is a simple answer.

I have a database that where I am trying to setup a security login
based on employee number.

Employee number is a 5 character numeric field. The databse has a sql
odbc link into the HR system to pull the emp number, emp name, and a
few other key fields. Because of the way the sql/odbc link is - this
field is a text field

Example emp numbers are:
00063
01222

On the login form, I have an unbound text box.

I've put an input mask of "00000" and default value of 0

I would like to make it so that the data entry starts from the right
side of the box. In otherwords, I would like to make it so that if the
person with employee number 63 goes to login, he only needs to type in
63 and not 00063. I would like the field to automatically add the
preceeding zeros if necessary.

Aug 8 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
LFM wrote:
I am sure there is a simple answer.

I have a database that where I am trying to setup a security login
based on employee number.

Employee number is a 5 character numeric field. The databse has a sql
odbc link into the HR system to pull the emp number, emp name, and a
few other key fields. Because of the way the sql/odbc link is - this
field is a text field

Example emp numbers are:
00063
01222

On the login form, I have an unbound text box.

I've put an input mask of "00000" and default value of 0

I would like to make it so that the data entry starts from the right
side of the box. In otherwords, I would like to make it so that if the
person with employee number 63 goes to login, he only needs to type in
63 and not 00063. I would like the field to automatically add the
preceeding zeros if necessary.
In your AfterUpdate event of the field you could do something like
Me.SecID = Right("00000" & Me.SecID,5)
Aug 8 '06 #2

P: n/a
You can do this by inserting the following code:

Public Function InsertZeros(Digits As String)
Dim intZeros As Integer
For intZeros = 1 To 5 - Len(Digits)
InsertZeros = InsertZeros & "0"
Next
InsertZeros = InsertZeros & Digits
End Function

This is a function that return the string with the zeros added to the
front.

You can run it from the debug window if you want to test it, by typing:

? insertzeros (63)

Will return:

00063

Good luck

Nick
LFM wrote:
I am sure there is a simple answer.

I have a database that where I am trying to setup a security login
based on employee number.

Employee number is a 5 character numeric field. The databse has a sql
odbc link into the HR system to pull the emp number, emp name, and a
few other key fields. Because of the way the sql/odbc link is - this
field is a text field

Example emp numbers are:
00063
01222

On the login form, I have an unbound text box.

I've put an input mask of "00000" and default value of 0

I would like to make it so that the data entry starts from the right
side of the box. In otherwords, I would like to make it so that if the
person with employee number 63 goes to login, he only needs to type in
63 and not 00063. I would like the field to automatically add the
preceeding zeros if necessary.
Aug 8 '06 #3

P: n/a
did you try format?
?Format(202,"00000")
00202

you could put it in the BeforeUpdate property of the control.

Aug 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.