Format of text box

  • Thread starter Thread starter Gareth
  • Start date Start date
G

Gareth

I have 2 text boxes on my form, both of which are for users to enter
customer reference numbers into.

The format of the first is 00/000/0000 (the 0's being the numbers 0 - 9).
What happens is that users will only put 55/12/3 into the box, I would like
Access to put in the missing 0's so that the entry is 55/012/0003

The second box is A0000000 (again the 0's being the numbers 0 - 9). If the
user enters 1615 I would like A0001615 to be the value in the field. Also,
if A1615 was entered then put A0001615 intop the field.

Thanks in advance.

Gareth
 
One option would be to use an Input Mask for the textbox. This will force
the user to enter the data in the format you desire.

Another option for the first box would be to make the 3 sets of numbers 3
different fields.

The last option is to use the AfterUpdate event of each textbox to parse the
string entered and insert the zeros. This will take a bit of coding. The
functions you will need are Len(), Left(), Right(), and Mid(). You would
break the string apart at the "/s" or after the "A", add the zeros as
necessary, then concatenate the string back together.
 
Back
Top