Prevent duplicates in sub form

N

Nick

I am using a sub form that has autoID(Primary KEY), EntDate , Catagoryrec
using radio buttons that range from 1 to 5 and HRTime. I can have the same
date for more than one catagoryrec but want to prevent duplicate
catagoryrec entries of that EntDate. As an example I could not enter two
record entries with EntDate 11/23 with radion button or catagoryrec2
selected. I would like an error message stating that I have entered duplicate
data for this catagory and date and ask if I want to save entry Yes/No.
 
A

Allen Browne

Create a unique index on the combination of EntDate + CatagoryRec.

Steps:

1. Open your table in design view.

2. Open the Indexes box (Toolbar, or View menu.

3. On a blank row below any existing entries, enter a name for the index and
the first field:
EntdateCategoryrec EndDate

4. In the lower pane of the dialog, set Unique to Yes.

5. On the next row of the dialog, leave the index name blank and enter the
2nd field:
CategoryRec
This indicates that the field is part of the same index.

6. Save the table. Access will ask you if you want it to check whether
existing data violates the index; you decide if you want it to do that or
not.

Notes:
=====
a) If the date field has time values as well, it may not work as you expect.

b) Consider whether you also want to set the Required property to yes for
both fields. (Nulls are not unique.)

c) I've suggested the date first, because this will give you an index on the
date.
 

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