473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Number entry (leading zeros)

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
3 3064
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
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
did you try format?
?Format(202,"00000")
00202

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

Aug 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: samik_tanik | last post by:
I need to export a datagrid to Excel. I could did this. But, also need to keep the leading zeros in the data. How can I acheive this? Any help would be appreciated. -- Thanking you in...
2
by: Reggie | last post by:
It's kicking my butt. All I want to do is add 1 to each new records I add to my table using a form. The serial number is in the form 0001, 0002, 0003 etc, and increments for each record. If I...
3
by: jj | last post by:
example is I'm finding the max number within a certain criteria, and then adding one to that. However, most IDs are something like K00001 or R00223 So I want the next ID to be either K00002 or...
8
by: shumaker | last post by:
I see other posts where some say fields that will hold a number with leading zeros should be stored as text instead of numbers. This is very inefficient though, as a string of digit characters...
3
by: brad.goldberg | last post by:
Hey All, I know this has been addressed in a few different conversations but none are exactly what I am trying to do, bear with me I am an access Newbie. Basically I have a form that assigns...
4
by: HandersonVA | last post by:
will it be possible to increase number as below automatically 00000001 00000002 00000003 .... whenever the row is inserted, number will be increased like above format. which data type should...
29
by: fdmfdmfdm | last post by:
let's say without checking including files, how do we to represent the biggest say int in a system? I ran across a book give this code: long int biggest = 0x7FFFFFFF; Does that mean the...
23
by: neha_chhatre | last post by:
which is the best format specifier(data type) if i have to work with decimal number. also please tell me the syntax for truncating a decimal number please reply as soon as possible
0
by: Monty | last post by:
Hi All, I am having a problem with leading zeros being stripped from fields in a CSV file when I bring them in using Jet/OleDB. In VB.Net/VS 2008, I am accessing a CSV file like so: sSQL =...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.