indexed field is allowing diupicate records in form view

M

mark kubicki

I have a field who index property is set to 'yes', disallowing duplicate
records
in table view this works, and duplicate entries are not accepted...

however, in a form view, duplicate records are being accepted, (as long as
the user desn't try to move to a different record -which they can't, and
then no reson why is diplayed ...ex: entry for [field] is duplicate and not
acceptable...) -this is a problem... (obviously)

Is this something i need to write code to deal with, or is there another way
around it?

suggestions?

thanks in advance,
-mark
 
S

strive4peace

Hi Mark,

you can use the form BeforeUpdate event to validate the data
and issue a message to the user that what they have entered
is not allowed if the combination already exists


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
M

Marshall Barton

mark said:
I have a field who index property is set to 'yes', disallowing duplicate
records
in table view this works, and duplicate entries are not accepted...

however, in a form view, duplicate records are being accepted, (as long as
the user desn't try to move to a different record -which they can't, and
then no reson why is diplayed ...ex: entry for [field] is duplicate and not
acceptable...) -this is a problem... (obviously)

Is this something i need to write code to deal with, or is there another way
around it?


You should get a duplicate key error message when the from
attempts to save the record. If you are not, then I have to
suspect that you have done something to suppress it.

If you want to check for a duplicate value before trying to
save the record, use some code in the text box's or form's
BeforeUpdate event to check if the table already has a
record with that value. This is a simple way to do it:

If DCount("*, "the table", _
"[the field] = " & Me.[the text box] Then
ErrMsg "Already used, try again"
Cancel = True
End If
 
Top