Do I use validation to ensure that only x, y, z can be entered in a Table field?

tyladea

New member
Local time
Today, 22:24
Joined
Sep 3, 2008
Messages
1
Hi guys,

I am a total Access newbie and have recently started a tafe course on the subject, so forgive my really basic question!

I am trying to create a 'Title' field that will only accept Mr, Mrs, etc. I'm sure there is a super simple way to ensure that only those strings can be accepted but it is eluding me at the moment!

My other question is in regards to the primary key field for my Customers table.. Is there any way I can use an AutoNumber field but have it format so the field is 'C001, C002' etc, or will I have to use a Text field, mark it PK and then enter these values manually? If the second option is true, what would the input mask look for something such as "C001", "S001" etc?

Thanks so much for your help! Hopefully at some stage in the near future I'll be able to help out the newbie's who will take my shoes :)
 
a. The simple way to do this is to utilize the lookup option for the field in design view. Y can also do a like method in a form design view for the text box.

b. You can't do this with the autonumber. I would create a small pop-up form that would let the user select the leading alpha character and then autofill the numeric part by looking at what the next value in the series would be for the chosen alpha part.

Hope this all made sense -
 
Just to add to Kens advice:
Autonumbers make great primary keys, I never use anything else. But they are lousy for numbers that users will see. What I would do is use an autonumber for the PK but never let the user see it. If you want an ID that the user will understand, then create your own. There is help in these forums if you search for something like 'incrementing number'.

As far as your title is concerned, remember in the real world, people can be Dr., Professor, Lord, etc, etc. So restricting user choice is more problematic. For a learning exercise, then use the validation rule, or what I would do is use a separate table with valid titles and get the user to choose one using a combo box in a form. But that may be too advanced for you!
 

Users who are viewing this thread

Back
Top Bottom