Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
AutoNumbers and Primary Keys
MUBEEZI 

16 years ago
Q: When we register patients, we give them unique "numbers" like NY/2010/043 but the presence of "NY" plus forward slashes make it better suit a "text" rather than a number. Initially i had used such a number as a primary key because they are actually unique for each patient but i got stuck when i wanted to write VBA commands to open a form and show specific records. I had to rebuild my database and use autonumbers. Is it possible to use text fields as primary key?

A: You CAN use a text value for a primary key, but you really shouldn't. In my personal opinion, every table should have an Autonumber ID. That's purely a value that is used for lookups and to relate records from table to table.

If you want to create a SECOND key value (such as your custom text) that's perfectly fine. In my own database, for example, I have an OrderID (AutoNumber) and an OrderNumber which is a unique number that my web site assigns based on the date, time, and server session variable - since it can't possibly know what the next Autonumber in my database would be. You can make this a unique value if you want - even index it, search on it, etc. But you should still have that primary key Autonumber as your ID.

And no, you really can't "manipulate" Autonumbers even with VBA. Once they're assigned, they're set for life on that record. You can delete the record, compact the database, and reuse some Autonumbers, but that's about it.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/16/2026 11:16:17 AM. PLT: 0s