Check for double field values

H

Harmannus

Hallo,

I have a table with the below fields. How can i check for double field
values?

So if all the below mentioned values are the same it should pop-up a
messagebox stating "Identical Field values already accist. Please change
current values"

Table:
tblSchedule

Fields:
ScheduleID
ScheduleDate
ScheduleEmployeeID
ScheduleCustomerID

So if Date, EmployeeID en CustomerID are the same/already accist it should
trigger a warning.

Thanx for any tips.

Regards,
Harmannus
 
B

Bob

You need to make ScheduleDate, ScheduleEmployeeID and
ScheduleCustomerID the primary key for tblSchedule. A
duplication of all three will trigger a warning that
duplicate records exist in the table with those values.
 
H

Harmannus

Hallo,

Thanx for the response!

I do not understand. There can only be 1 primary key in a table (to my
knowledge). How do i make those 3 fields the primary key as they are all in
the same table?


Regards,
Harmannus
 
J

John Spencer (MVP)

You are right, there can be only one primary key in a table, HOWEVER, the
primary key can consist of multiple fields (no nulls allowed).

You can also use a compound index that is set to allow no duplicates. This does
NOT have to be the primary key.

To create a multiple field unique index
--Open up the WorkingTable in design mode
--Select View: Index from the menu
--Enter Name for Index in first blank cell under Index Name
--Select one field in the index under Field Name
--Set Unique to Yes
--Move down one line and select the next FieldName
--Continue moving down and selecting fieldnames until all needed are included.
--Close the index window and close and save the table
 

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