Prevent duplication in a field

  • Thread starter Thread starter Ken
  • Start date Start date
K

Ken

Hi
(Access 2003) Is there any way to check that the data typed into a field
(e.g. 201-150-500) is not duplicated as I leave the field, not after
exitinng after all of the form is filled in as happens now
Regards
Ken
 
Use the control's before update event to check your values. If you want to
stop the update then:
MsgBox the user
optionally Me.controlname.undo
Cancel=True
Me.controlname.setfocus
 
Use the DLookup() or DCount() function in the BeforeUpdate event of your
control to check for duplication and set Cancel = True to hold the focus in
the control.
 
Hi
All I was after was a simple message to say, already exists
I am not sure how to write VBA code, although I am familiar with properties
and where to look at the variuos VBA codes for each field in a form.
Regards
Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top