Runtime Error

Shallo9

Registered User.
Local time
Today, 10:51
Joined
Nov 11, 2011
Messages
95
Hello,

I have a form and a subform. On my parent form I have a field called "IssueId" and a tab control on which I have put my subforms (on each tab a subform which are all related to the IssueId on my parent form). The field “IssueId” is a unique field, so I can’t create double records for one IssueId. Everytime I add a new record (IssueId)I get the following error message :

Run-time error “3201”
You cannot add or change a record because a related record is required in table “tblIssues”.

The problem is the record in my parent form needs to be saved first before I can add records in the subform. I've tried to put the line "docmd.runcommand accmdsaverecord" in the last field of the main form but it does flag the same error again .
 
This error signifies you are attempting to violate referential integrity. It seems you are trying to add "child records", before you have a "parent record".

You will have to ensure the Parent record exists before adding a child record.
 
But apparantly In Access as soon as I get focus onto the sub form the main forms data is saved to the underlying table. So do i need to do anything before that to ensure that the parent record is saved?
 
You haven't told us what table relates to what form and what the relationship between the tables is.
 
You haven't told us what table relates to what form and what the relationship between the tables is.

the main table is issues with a primary key Issue Id and the sub form has a table called activities where activities related to an Issue Id. its a 1-2-Many relationship
 
And is the subform linked to the main form via Issues ID using the Link Master Fields and Link Child Fields properties?
 
And is the subform linked to the main form via Issues ID using the Link Master Fields and Link Child Fields properties?

Yes it is indeed. I've just dragged n dropped the child table into the main form onto a tab control and made it a datasheet view.
 
Can you upload your db for me to look at? I don't need confidential data just test data with the relevant objects.
 
Can you upload your db for me to look at? I don't need confidential data just test data with the relevant objects.


Unfortunately I cannot as there is a lot of confidential data on my forms n tables and it is too much work for me to replicate the db with dummy data..Thank you anyways...
 
It's up to you. You only have two tables and two forms to replicate.
 
It's up to you. You only have two tables and two forms to replicate.

Not exactly the response to your suggestion but I've just realised that the fields in the main form are actually connected through a query which inturn is pulling or pushing data to three different tables (though all three use the same issue ID). Is that some thing I shouldn't be doing? However I am gonna try to bound the fields to the actual tables and not the qry N let you know what it causes.

Many Thanks
:confused:
 
It's up to you. You only have two tables and two forms to replicate.

Hey Hey VbaINet@ I've sorted it out...I was so Naive with this problem spent donkey's ears on this but i am glad I've found it. I've had a one to one relationship but forgot to lookup from the sub-table and rather was generating autonumber..I hope you got what I am tryin' to say...but thanks a lot for your moral support...That shall put n end to my sleepless nights.:D:D:D
 
Hmmm... I thought you said it was a one-to-many.

Glad to hear you've got it fixed.
 
Just fyi: Bind your forms to the least number of tables and connect the subforms via the appropriate Foreign Keys. In your case, your subforms should be bound to one table.
 

Users who are viewing this thread

Back
Top Bottom