Hi All!,
here's my problem.
i'm working with Visual basic 6 and microsoft Access 2003 database.
I use ADO objects for connection and manipulation of the database.
In my database there are 3 tables .2 tables(Customers and Events) are the parent tables and 1 table(Orders) is a child table.The order table has one primary key(and 2 foreign keys).
i have no problem with the 2 parent tables.
My Main concern is with the Order table.

In my VB6 program , i have a form with text boxes used for inputing and outputing data and some command butons to save record or add a new record.

In fact ,i am able to use the Addnew and update (ADO)methods to save data entered in text boxes on a VB6 form.
The saving operation(update) goes well when the referential integrity is not enforced between the 3 tables mentionned above.

THE PROBLEM is when i enforce the referential integrity between the 3 tables.IN fact, the save(update method) operation "goes well" BUT a ERROR MESSAGE is always displayed on screen.(Error -2147467259)

in Fact, the complete error message displayed is "Microsoft OLE DB Provider for ODBC Drivers reports[Microsoft][ODBC Microsoft Access Driver]. The record cannot be deleted or changed because table ’orders’ includes related record."

Could you please explain to me why i have this error message ?
What can i do so that the error message doesn't appear any more?
:confused:How could i solve this problem ? :confused:

here are some lines from my code :
Dim objADOConn As ADODB.Connection
Dim objADORst As ADODB.Recordset

objADORst.Fields("Order_ID") = Val(Trim$(txtOrderID.Text))
objADORst.Fields("Event_ID") = Trim$(txtEvent_ID2)
objADORst.Fields("Customer_ID") = Trim$(txtCustomerID.Text)


i've tryed to search for a solution through google. some suggest to use sql insert instead of addnew and update, or remove connection options such as opendynamic,...but nothing seems to help!

Thanks in advance for taking your time to look at my problem!
have a nice day!

5 Years
Discussion Span
Last Post by dspnhn

as per the rule of referential integrity.

1. No child record can exist without a parent record
i.e.--Parent record must be created first and then the child record.

2. Parent record can't be deleted till there exists a dependent child record
i.e.-- Child record must be deleted first and then the parent record.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.