|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello!
I am working on an Access DB and I am fairly new to it. I have a Master table with a primary key called (CustID) which links to an invoicedetail table with a foreign key of (CustID). On my subform, when I enter the invoice details it is not updating the foreign key field so I get a message "You can't add or change a record because a related record is required in the Customer Master table. What do I need to do to get the foreign key field to update the data from the primary key. Any help would be greatly appreciated! |
|
#2
|
|||
|
|||
|
I think you may be expecting a little too much from a database constraint relationship.
All the foreign key does is create a link between 2 tables. You have to programatically keep the link in place. You cant say add a set of values to table b and expect the database to create a corresponding record in table A. You have to first create your record in table A thereby creating a new CUSTID. Then create your table B record using the newly created CUSTID as the foreign key. Now you use the foreign key constraint to maintain a link between the 2 tables. Thereofre if you were to look up the dat you could in theory say select * from tableA a, TableB b where a.CUSTID = 123 and b.CUSTID = a.CUSTID hope this makes some sense to you. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Foreign key linked to primary key-not updating |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|