Duplicate numbers recognition

G

Guest

I have a form that enters a number into my table. I want the database to tell
me if the number I am entering is a duplicate. Right now if I duplicate the
number it will let me continue but it does not save the latest information.
 
J

Jeff Boyce

Scott

Instead of using a textbox, requiring the user to remember/enter a
code/number, then refusing to accept the record because it is a duplicate,
it would be a lot more user-friendly to use a combobox that lists all
"current" values. Then you can set the combobox's LimitToList property and
use the NotInList event to add new items...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

In the Before Update event of the control on the form where the number is
entered, use a DLookup to see if the number in the control exists in the
table and cancel the update if it is:

Private Sub txtTheNumber_BeforeUpdate(Cancel As Integer)

If Not IsNull(DLookup("[TheNumber]", "TheTable")) Then
MsgBox "This Number Already Exists in the Table"
Cancel = True
End If
End Sub
 

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

Top