Primary key comparision

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a form that populates a table. The first thing entered is an order
number, which is the primary key in the table (it should never be
duplicated). There are quite a few fields to populate in the form.
Is there a way to compare the new order number entered to what's already in
the table as soon as the field is exited to make sure it's not a dup?

Thanks,
 
Hi, Marc.

If you make the order number your primary key, which you should, Access will
prevent anyone from entering a duplicate number. Better still, make the
OrderNumber an AutoNumber type, and let Access assign the order number.

Hope that helps.
Sprinks
 
Hi Sprinks,

The order number is the primary key. What I'm trying to avoid is the
operator going through the entire data entry screen before being notified
that they can't enter that order. Right now, if they enter a duplicate order
number, they can still tab to the other fields and enter data - not knowing
anything is wrong.

Thanks,

Marc

ps - good idea on the auto entry, but these are existing order numbers that
they get from the sales department.
 
Do a lookup with DLookup or DCount, or build a recordset and check if the
number exists in the text box's Before Update event. If the help files are
insufficient, post back with more detail and I'll build a sample for you.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top