Use "-" in the unique field

maximyshka
maximyshka used Ask the Experts™
on
Hi, does it make any difference whether or not I will use "-" in the Unique number field.

Example "1111111111-222222".  We have such field in master file for reporting purposes.

Unique field is the main field we use for programming, groupping, indexing, reporting etc.

Is this OK to use field "1111111111-222222" or I have to use field "1111111111222222" as primary key and use field ""1111111111-222222" for reporting purposes
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
Why not use the Access Auto Number as your Primary Key ... then it becomes a non-issue.

mx

Commented:
You can use "-" in a unique number field. However, it is obviously text and not a number. Neither will it be automatically incremented as an Autonumber type. Your only requirements would be uniqueness.

Author

Commented:
I have a field in the format 1111111121-2222222 which I want to use as primary key. Yes this field i text. Incrementing not needed
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Commented:
Then, yes, you may include and use the "-".

Lee

Author

Commented:
MX, autonumber will not work.  Value "1111111121-2222222" is uniquely identify all information about this loan.

Something similar to composite key

1111111121
2222222
Commented:
mx wasn't suggesting using your existing unique number field as an autonumber primary key. He meant using a separate field with autonumbering as your table's primary key.

You have a choice:
1. Add a new column to your table as an autonumbering primary key. You can set your existing column to unique values as well.
2. Use your existing field as your table's primary key. Only uniqueness matters, not the "-".

Lee
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007
Commented:
Exactly ... a separate field ...

Author

Commented:
Thanks a lot

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial