Validation/Check problem

filo77

Registered User.
Local time
Today, 04:11
Joined
Jul 13, 2004
Messages
16
Hey guys,

I need help pros. :)

I have a primary table whith a customerID (PK), also a form with a drop down menu, populated with all customerIDs, and another, secondary table, which is updated by the form in place.

In the secondary table I must not have two records that have the same customerID (customerID is not the primary key in this secondary table, this is the logic of the problem).

How do I create a macro or a procedure that checks if there is a record in the secondary table with the same customerID that has been selected from the form's drop down menu, and forbids the update/insert into this secondary table if this is the case? In other words this form must allow me to enter customer data in the secondary table only once per customerID.

Thank you very much for helping me with this.
 
filo,

First, you can create a unique index on the "Child" table. It can consist
of multiple fields, if required. Then you won't get duplicates.

Secondly, you can use the AfterUpdate event of the combo-box for the
CustomerID and use the DLookUp function to check if a record exists.

There are a lot of examples here if you use the Search facility and look
for DLookUp.

Wayne
 
Thank you WayneRyan.

I think I am going to try the AfterUpdate DLookUp combo-box.

It makes sense now that you said it.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom