Since everyone suggested that my primary key was not a good idea, I don't have any idea how to do this check. Any suggestions?
Hi tkosel,
For creating new records, I use an unbound New-form for entering the values.
When the Save-button is pressed, a number of checks are done, among others whether values are obligatory, fall in certain ranges, but also if some combinations of values may already exist in the table.
If all checks are passed, a new record is created with an autonumber as PrimaryKey, and the corresponding fields are filled. With no-pass there is no new record created, a message is generated, and the control with the problem-field gets the focus. This way of working ensures that only "correct' data is entered, while at the same time the minimal locking of recordblocks occurs.
In this case it is also not necessary to have an extra "redundant" field with an unique key.
I said when pressing the Save-button, in fact these checks are done in the BeforeUpdate event of each control on the New-form. The user gets a signal in a very early stage of the inut process.
In case of data-input through code (no user activity) there is no BeforeUpdate event. In that case the same checks are done, including if some combinations of fields already exists. If this exists, the corresponding Id (Autonumber) is returned; if it not exists, a new record is created, and the new Id is returned.
This is my best method. A further detail is that my New-form is a generalized form, so it works for any table in any of my applications. But it can also work with a dedicated New-form per table.
Imb.