Select 2 numbers of an ID-number

rarejoep

Registered User.
Local time
Today, 06:33
Joined
Oct 8, 2002
Messages
30
I am making a database of trainees. Every trainee has an id-number, that starts with the last 2 numbers of the year of birth. I want on the form a textbox or label that can show the age of that person. So it must calculate the year we are in right now minus the year of birth. Does anyone know how I can do this, how a query can select the first 2 numbers of a ID-number?
 
Add the following to the AfterUpdate Event of the Age textbox:

Me.IDNumberField = Format(Date - ((365 * Me.AgeTextBox) - 1), "YY") & "OTHER NUMBER OR CHARCTERS YOU WANT TO ADD"
 
Well, first off, you can create your own field in a query, just by typing the field name, a colon, and then what you want. For example, to get what you want:

TraineeNo:Left([ID-Number],2)

And if your field which has the id number is named ID-Number, the above will give you the first two digits.

Next as to the calcuation part, you can actually do something like this (and this is just simple math, not checking to see if they've actually past the month of their birth).

Age: (Right(Date(),4)-Left([ID],2))-1900

There's probably a better way for the calculation, but that will get it done until you have employees whose birthdays are year 2000 and on.
 
Thanks, it works. Is it a lot of work to make it work also with months and days?
 

Users who are viewing this thread

Back
Top Bottom