What is the best way to check whether the value is in the table

B

Boon

I have a table Customer. In table Customer, there is a field "ID".

The user will open a form and input a new ID, the VBA will then search
through the table Customer to check whether this new ID is already in the
table.
I use Dlookup, and if it returns null then there is no value. Is this the
best way to do? Is there a better way?

thanks
 
M

Marshall Barton

Boon said:
I have a table Customer. In table Customer, there is a field "ID".

The user will open a form and input a new ID, the VBA will then search
through the table Customer to check whether this new ID is already in the
table.
I use Dlookup, and if it returns null then there is no value. Is this the
best way to do? Is there a better way?


I think that's as good a way as any, if you really need to
check for it. If the ID field in the table is used as a
unique index, Access will not save the duplicate ID record
with a trappable error.

But, if you want to check for a duplicate value as soon as
it's entered, the go ahead and use DLookup in the text box's
BeforeUpdate event.
 

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