VBA Form / Subform add record

jerem

Registered User.
Local time
Today, 15:29
Joined
May 1, 2012
Messages
118
Hi,
I have a Form [Quotes] and a Subform [QuoteDetails]. In my form I created a dropbox with an AfterUpdate event to append new records in the [QuoteDetails] table automatically. The problem is that since my code creates the records directly in the table without going through the form, there is no record created at the parent level, the [Quotes] table. Therefore my record in the child table [QuoteDetails] cannot be created.

The error is: Run-time error '3201':
You cannot add or change a record because a related record is required in table 'Quotes'

Any work around?
 
Last edited:
The form/subform construct is really designed to work with tables that have a 1 to Many relation.
For example :
1 Student -- Many Courses
1 Order -- Many OrderItems
1 Quote .. Many QuoteDetails

Logically in the Quote/QuoteDetails set up, you must have a Quote before you can have a QuoteDetail. It's much like parents and children -- have to have a Parent before the Parent can have a Child/children.

Research Referential Integrity.

Here are some links
http://databases.about.com/cs/administration/g/refintegrity.htm
http://en.wikipedia.org/wiki/Referential_integrity

There is no work around as such. You must create the Quote record before you can add a QuoteDetail record.
 
Thank you Jdraw. I made sure the record was created from the subform so that it generates a record in the parent table as well.
 

Users who are viewing this thread

Back
Top Bottom