Null Primary Key

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

I have an issue relating to the primary key:

On a certain form in my database, if you go to a new
record you cannot get off of it until you enter data in
the primary key. I have always been able to go to a new
record and then go back if need be. I have an OnCurrent
event that makes a few fields not enabled if another is
null, so maybe this is updating the record when I go onto
it? I have tried endlessly to fix this, so any help
would be great! I am using Access 2002.

Michael
 
Dear Michael,

One can't have a NULL primary key, it is a sin against the
first rule of relational databases.

Wim
 
I understand this, but go to add a new record, notice you
have the option of going back a record without having to
fill in anything on the new record including the primary
key. If you do start to enter anything then all the
default values are filled in and the form looks for you
to enter a primary key, but if you go to a new record and
do NOTHING, you should be able to go back. Understand
now?

Then either a macro or code is "doing something". If not, then it should
be just as you describe. You should be able to navigate to the new record
position and as long as you don't do anything to start a record then you
should be able to close or navigate somewhere else without a problem. If
you have a macro or code that is setting a value in the background then
that is why it is forcing you to fill out the rest of the record.
 
I agree with Rick. You code must have assigned some value or something that
flag the Form's Dirty Property to true.

If you want to back out without saving, you need to use the Undo Method of
the Form to remove the data entry (by your code or user) before you can back
out. If you only want to use the GI, you can use the Escape Key, possibly
twice (the first Escape undoes the current Control, the second Escape undoes
the Form) and then back out.
 
Back
Top