Question about Subforms and Relationships

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have opened the template called "Order Entry". In it ther is a Form called
Orders and inside that is a sub-form called "Order Details Subform" In the
Main form "orders is a field called Employee ID, if I do not enter that first
and then I go into the subform and enter prouct purchased, etc and try to
come out, I get an error that says "You can not add or change a record
because a related record is required in the table "Orders". if I enter the
employee ID, everything is fine.

I used this same template in 97 and it workd even if I left out the
EmployeeID. Now in Access 2003 I get this error. How do I get around this?
Thanks
 
Your Orders table has a field called Employee ID, which (presumably) is a
foreign key that refers to the Employee ID of an Employee table?

1. Open the Orders table in design view.

2. Select the Employee ID field.

3. In the lower pane of table design, remove the zero from the Default Entry
property.

Access assigns a zero as the default value for all Number fields. This makes
absolutely no sense for a foreign key field: if you have no employee whose
primary key is zero, you get the message that the entry does not match.

You may also need to open the Order Details table, and remove the Default
Value from the OrderID field. BTW, you probably should set the Required
property of this field to Yes while you are there. That prevents the
situation where you are able to enter a record in the subform even if there
is no order in the main form (i.e. the main form is at a new record.)
 
Back
Top