MHutcheson
Registered User.
- Local time
- Today, 16:38
- Joined
- Sep 3, 2013
- Messages
- 23
Ok, in a nutshell:
tblCustomers has a one to many to tblJobHead (referential integrity)
tblCustomers PK = RepNum
tblJobHead FK = RepNum
Within a navigation form, I have a form that contains the tblCustomer info in the header section and the tblJobHead in the detail.
I also have a button, when the users clicks this it brings up all items for the user to search from the table tblItems. This search form is in the Continuous Forms view and against each item is a button. Behind this button is the following code:
=====================================
Private Sub Command18_Click()
Dim R As Recordset
Set R = CurrentDb.OpenRecordset("SELECT * FROM [tblJobHead]")
R.AddNew
R![Rep Num] = [Forms]![frmMain]![NavigationSubform].[Form]![RepNum]
R![Item Number] = Me.ItemNumber.Value
R![Description] = Me.Desc.Value
R![EmpID] = [TempVars]![EmpID]
R.Update
R.Close
Set R = Nothing
End Sub
====================================
However, everytime this button is clicked I receive the following:
Run-time error '3201':
You cannot add or change a record because a related record is required in table 'tblCustomers'.
However ,the RepNum already exists in the tblCustomers table and is the foreigh key to tblJobHead, with referential integrity - so why is access saying the record does't exist in the tblCustomers table?
oh, and I'm using Access 2010 32 bit.
Any help would be greatly appreciated.
Regards,
Michael
tblCustomers has a one to many to tblJobHead (referential integrity)
tblCustomers PK = RepNum
tblJobHead FK = RepNum
Within a navigation form, I have a form that contains the tblCustomer info in the header section and the tblJobHead in the detail.
I also have a button, when the users clicks this it brings up all items for the user to search from the table tblItems. This search form is in the Continuous Forms view and against each item is a button. Behind this button is the following code:
=====================================
Private Sub Command18_Click()
Dim R As Recordset
Set R = CurrentDb.OpenRecordset("SELECT * FROM [tblJobHead]")
R.AddNew
R![Rep Num] = [Forms]![frmMain]![NavigationSubform].[Form]![RepNum]
R![Item Number] = Me.ItemNumber.Value
R![Description] = Me.Desc.Value
R![EmpID] = [TempVars]![EmpID]
R.Update
R.Close
Set R = Nothing
End Sub
====================================
However, everytime this button is clicked I receive the following:
Run-time error '3201':
You cannot add or change a record because a related record is required in table 'tblCustomers'.
However ,the RepNum already exists in the tblCustomers table and is the foreigh key to tblJobHead, with referential integrity - so why is access saying the record does't exist in the tblCustomers table?
oh, and I'm using Access 2010 32 bit.
Any help would be greatly appreciated.
Regards,
Michael