Forum Discussion
Key Field Question
I'm trying to create a database with a key field containing 1a, 1b, 2a, 2b, 2c, etc. If I make this a text field it does not sort properly. Is there a way to do this? Thanks for your help.
10 Replies
- XPS35Iron ContributorThe most logical is to split the field into two fields. After all, these are two different pieces of data: card number and variation.
An other solution is to insert lading zeros (01a, 02c, 11d).- dluhopCopper ContributorOK, good. That seems like a good solution. Text field with leading zeroes. Thanks.
- George_HepworthSilver ContributorAs is always the case, there are multiple approaches to problems.
One is to apply a band-aid to the symptom and move on, hoping other, similar, problems don't pop up.
The other is to identify the root of the problem and correct that, so the symptom goes away.
Choose wisely.
- George_HepworthSilver Contributor
Define "sort properly", please.
Also, what is the goal here? When Access developers see the words "Key fields" we think of something very specific, so it may be that an appropriate answer would depend on why you are creating this field and what you plan to do with it.
- dluhopCopper ContributorI'm pretty much a novice when it comes to Access. I thought a key field is a unique identifier for a particular record in a table. I just want to be able to add cards to the table and have them be sorted in the right place.
- dluhopCopper Contributor
George, thanks for replying. I have a set of baseball cards that are numbered 1 thru 24. Some of them have variations. The variations of the first card should be numbered 1a, 1b, 1c, etc. If this is a text field, they sort 1, 11, 2, 20, etc. I could do 1.1, 1.2 as a numeric field but I really don't want to do it that way. I hope I'm explaining this so you can understand.
- arnel_gpIron Contributorwithout Splitting your field, you can sort on:
ORDER BY Val([FieldName]), Right([FieldName],1);