Validating an attempted insert

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

tblEnrollment has the following 3 fields:

EntrantID
Date
SessionID


Before my application can insert a record in this table, it has to be sure
that the same combination of EntrantID, Date and sessionID does not already
exist in the table. I realize that I could use a composite primary key of
the 3 fields to prohibit the duplicate record from being inserted, but I just
want to provide a warning message, whereby a user could cancel the insert or
accept it.

The data values will be selected in a subform. I'm thinking that I would
need code at the subform level to validate when the insert is attempted.

Any idea how the code should be written?

Thanks,
Jody
 
Jody

"Date" is a reserved word in Access -- use something else.

If you set a unique index on the table across those three fields, Access
won't let you add another "matching" set.

If you are to be able to distinguish one enrollment from another, the user
probably should NEVER be allowed to accept the duplication.
 
Jeff,

Thanks for the suggestions, but in fact I want to allow duplicate entries as
I stated in my original post. So, do you know how to write the code to do
this?

Thanks,
Jody
 
Jeff,

A thought occured to me that was provoked by our conversation. I think I'll
add a 4th field to the composite primary key - requiring a user to supply a
number indicating how many entrant enrollments have occurred within the same
date and session.

Cheers,
Jody
 
Back
Top