chrisjames25
Registered User.
- Local time
- Today, 23:31
- Joined
- Dec 1, 2014
- Messages
- 401
Hi.
I have an invoice form with a invoice detail section and a subform with a list of prodcuts associated to he the invoice. See image of my form.
The subform is not the actual invoice_product details table but in fact a neater query.
The subform is locked and the products are added to the invoice_product details table by cycling through a product details section in the main table and on clicking add product the following code runs
This worked great till i started coding my cancel invoice button and changed the relationship between the two tables to enforce cascading deletes. When i now try to enter a new product to an invoice i get the following message:" Run time error 3201 - You cannot add or change a record because a related record is required in table 'tbl_invoices".
Within the form it is clear that the current record has gone from new to populating an auto number in invoice_ID but has it not actually updated that record yet and if not how do i get it to update the record at the start of the above code.
Many thanks for your help on this one.
I have an invoice form with a invoice detail section and a subform with a list of prodcuts associated to he the invoice. See image of my form.
The subform is not the actual invoice_product details table but in fact a neater query.
The subform is locked and the products are added to the invoice_product details table by cycling through a product details section in the main table and on clicking add product the following code runs
Code:
Set db = CurrentDb
Set rs = db.OpenRecordset("Tbl_TempInvoiceDetail")
rs.AddNew
rs.Fields("Variety_ID") = Me.Lst_SearchResults.Column(6)
rs.Fields("Batch_ID") = Me.Lst_SearchResults.Column(0)
rs.Fields("TrayQty_ID") = Me.Lst_SearchResults.Column(7)
rs.Fields("NoOfTrays") = Me.Txt_HeadNoOfTrays
rs.Fields("AdditionalPlants") = Me.Txt_HeadAdditionalPlants
rs.Fields("Invoice_ID") = Me.Txt_Invoice_ID
rs.Fields("TotalPlants") = Me.Txt_HeadTotalPlants
rs.Update
rs.Close
Set rs = Nothing
db.Close
Me.Frm_ChildInvoiceForm.Requery
'Me.Frm_ChildInvoiceForm.SetFocus
'DoCmd.GoToRecord , , acLast
Me.Frm_ChildInvoiceForm.Form.Recordset.MoveLast
This worked great till i started coding my cancel invoice button and changed the relationship between the two tables to enforce cascading deletes. When i now try to enter a new product to an invoice i get the following message:" Run time error 3201 - You cannot add or change a record because a related record is required in table 'tbl_invoices".
Within the form it is clear that the current record has gone from new to populating an auto number in invoice_ID but has it not actually updated that record yet and if not how do i get it to update the record at the start of the above code.
Many thanks for your help on this one.