MS Access Number Field

Deon Olivier 101 Reputation points
2022-01-03T10:58:08.367+00:00

Hi all,
I have a Access 206 database where student details are recorded. One of these fields, is an ID field which consists of 13 digits. The first 6 digits, is the birth date of the student. Typically, if the person was born on 31 May 1965, the first six digits would be "650531" ...
These six digits is used to complete the "Birth Date" field on the form as soon as the lost focus event is triggered.

My issue is that I never took into consideration when a person is born in or after 2000. So if the person is born on 31 May 2003, the first six digits of the ID is entered as "030531", but when the lost focus event is triggered, Access throws away the leading zero, truncating the field to "30531", which results in an error.

Any suggestions how I can change to accept the ID if a person is born in or after 2000?

Thanks
Deon

Microsoft 365 and Office Access Development
0 comments No comments
{count} votes

Accepted answer
  1. Gustav 717 Reputation points MVP
    2022-01-03T11:03:24.857+00:00

    Apply a format to the textbox where you display that number:

    0000000000000

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Deon Olivier 101 Reputation points
    2022-01-03T13:05:46.203+00:00

    Hi Gustav,
    Applying a format does not work. I have changed the field property to be a "Short Text" field and it seems this solved the problem.

    Thanks

    0 comments No comments

  2. Deon Olivier 101 Reputation points
    2022-01-06T08:48:30.57+00:00

    Hi Gustav,
    I have played around with your format suggestion. It will work to display the ID correctly on the screen, but when I save the ID, it is saved without the leading zero (201315555288)

    Is there perhaps a way to save the ID including a leading zero (0201315555288)?

    Thanks
    Deon

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.