View Full Version : prevent user duplicating records in a subform


Herriot
02-12-2002, 03:20 PM
Hi folks can anyone help please...

My database is a simple stock control one, you'ld think. The stock in question is work garments. I have two tables; tblsizes, tblstock. The tblsizes table has the following fields Size_id (autonum key field); Stock_ID (number); Size (text, cos it could include large, medium etc as well as numerical sizes); Qty (number). The tblStock has the fields Stock_ID (autonum key field) Stock_description. Both tables are linked by the STock_ID field in both tables.

I have a form (frmStock) and this has a subform (frmSizes Subform). The user can enter the stock and the sizes and quantity of each size. The fields in the subform are displayed in datasheet view.

I hope there is sufficient "meat" in the above for you to be able to answer this question...

**How can I prevent the user putting duplicate values in the Size field? I have managed to prevent the user from inputting a duplicate Stock item, I.E user can't have two records named gloves. But the same routine doesn't seem to work with the Size field in the "frmSizes subform"

For example how can i prevent the following from occurring:


*Main form
Stock: Gloves

**Subform
Size QTY
Med 2
Med 3
Large 4

I made the the size field "YES (no Duplicates) but this just meant that no size could be repeated. It is obviously possible to have the same size in two different garments but not in the same one.

Any help would be gratefully received

Regards and TIA,
Herriot