Probelm On Subform - Cannot Add Or Change Record

G

Guest

Hi;

I have a main form PhotosEntryForm with a subform on it InvoiceForm
When I try To add invoices to the Invoice subform I get -You cannot add or
change a record because a related record is required in Table Invoice
Both forms properties are set to Data Entry

What's causing this error message
 
B

Ben

Hi Terry,

You've been a but sparse with your info here but I have an idea what's going
on!

Assumptions: You have two tables, tblPhotos and tblInvoice . The Invoice
table contains a foreign key to the Photos table. You have a relationship
that a Photo record may have many invoice records. All invoice records must
have a related Photo record.

If you have both form and subform in dataentry mode, and try to directly add
a record in the sub form, you will get an error, as the "parent" photo
record does not (yet) exist. As it should be.

If you add the photo record first, you should then be able to add records in
the subform. If you get an error at this stage check that:

- The "Link Child Fields" and "Link Master Fields" are correct. In my
example above they should both be "photoid" - the name of the primary key of
the Photos table, and the name of the foreign key field that is used in the
invoice table.

- You have not set a "default value" on the "photoid" field in the subform.
Access "cheats" in subforms to automatically set the foreign key value to
the correct value when creating a new record. However, there are various
ways you could override this and cause the error.

Let me know if this is useful! If not, give some more information -
describe what you want to happen, how you've attempted to make it happen,
and what is actually happening and I'm sure I (or someone!) will sort you
out.

All the best,

Ben.
 

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