Problems with text primary key and add new record

mack

New member
Local time
Today, 02:41
Joined
Nov 30, 2009
Messages
3
Hello everyone, I'm new and I'm writing from Itlay (sorry for my english)
I'm working on a MS Access Db built by another person.
This Db has all the tables' primary keys set with simple text fields (and not with autoincrement values).
To add a new record I know that previously it was used a function (or something similar). This method consisted (more or less) in reading automatically the last Id number, increment 1 and write it in the new record's field.
Did anyone ever faced something like this before? Can I do something similar? (maybe with a query?)
Any suggestion will be very appreciated.....
Marco
 
It's quite a common method chosen by people to implement automatic numbering systems that require a more complex sequence than can be done with a plain autonumber.

If you're looking for the code that does this in the database you've been given, I suggest:

-Looking in the BeforeInsert or AfterInsert events for the main form, or
-In the VBA editor, search the entire project for the term: DMAX

If you just want to know how to implement this sort of custom autoincrement, try searching these boards for: Custom Autonumber
 
My question is WHY? Why not just use an Autonumber for the PRIMARY KEY. The PRIMARY KEY is ONLY for the benefit of the system, so why not let the system manage those? Why go through all of the hassle to recreate the wheel? You can have whatever number you want for display purposes to the outside world, but for the internal workings (maintaining the relationships between data) use a surrogate key (i.e. Autonumber) and make your life easier.
 
Dear Bob, your question is my question too!!!! I don't know because the db was created by another person and given to me that way; I have to create a web interface but this question is a real trouble for me! So....
 

Users who are viewing this thread

Back
Top Bottom