NO DUPLICATES ALLOWED and NO ERRORS ABOUT IT

  • Thread starter Thread starter Sammie
  • Start date Start date
S

Sammie

I have a form used to enter new records in response to a not-in-list
event. It contains 2 fields which do not allow duplicates. Niether of
these two fields is the primary key. The problem is that the user
doesn't see that they have entered a duplicate until after they have
closed the form and they receive an error on the not-in-list event. How
can Access prevent the user from entering a duplicate right when they
leave the particular field which doesn't allow duplicates, so they know
exactly why it is not an acceptable entry? I'm having too much trouble
writing error handling code on my not-in-list procedure, when I think
it's the duplicates on the other form that are causing the problem.

Thanks.
Sammie
 
... How can can Access prevent the user
from entering a duplicate right when they
leave the particular field which doesn't allow
duplicates, so they know exactly why it is
not an acceptable entry?

I am not certain how this question applies to "Access Reports", the subject
of this newsgroup. This certainly seems a good candidate for
microsoft.public.access.formscoding or microsoft.public.access.forms.

However, the usual method to do what you want is to write code in the
BeforeUpdate event of the Control that reads the underlying data to see if
there is a duplicate in that field , and if so, sets Cancel = True before
exiting the event procedure, possibly issuing a MsgBox to the user.
Depending on your design, you may be able just to do a .FindFirst on the
Form's RecordsetClone.

Larry Linson
Microsoft Access MVP
 
Back
Top