PDA

View Full Version : How to set up a table



lifeson
12-09-2008, 09:24 AM
How do I set the validation for a table (tblResults) which contains weekly sales results.

The table has fields including "payNo" and "WeekNo"

The PayNo field is linked to a TblEmployee - payNo is the primary key
The WeekNo field is linked to tblSalesPeriod - WeekNo is the primaryKey

I want the table to allow multiple records for each employee but each employee can only have one record for each weekNo.

OBP
12-09-2008, 10:13 AM
Excellent, a Many to Many Linking Table. As you want only one Weekno per employee you have a bit of a problem.
I would get around this by having a another field which I would call Combined because it combines (concatenates) the Weekno and the Payno. In this Field I would set the Indexed property to "Yes with No Duplicates".
On the Input form where you Enter the data for the Table (Ideally by selecting from Combo Boxes) I would add some simple VBA to the Weekno and Payno fields After Update Event Procedure like this
me.combined = me.weekno & " - " & me.payno

If you use combos the VBA could go in the Combos instead.