doctorswamp
Technical User
This is an extension of ane earlier question, and thanks to Remou, TheAceMan1 and PHV for help with that.
Have main form frmCustomers containing customer details and a subform with items tready for delivery to them, as a datasheet.
I want to enter a DeliveryNoteNo in the main form and apply it to items appearing in the subform. The subform derives from a query based on tables JobItemsReadyForDespatch and Customers.
Three parts to the question
1. I've created DeliveryNoteNo as an unbound textbox and added this After Update procedure
Private Sub DeliveryNoteNo_AfterUpdate()
Dim strSQL2 As String
strSQL2 = "Update JobItemsReadyForDespatch Set DeliveryNoteNo = [forms]![frmCustomers]![DeliveryNoteNo] where Customer='" & Me.Customer & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL2
DoCmd.SetWarnings True
End Sub
This applies the DeliveryNoteNo okay but to all records, not just the chosen customer's. I think the problem is the Where bit, since the Customer field isn't in table JobItemsReadyForDespatch but in the query.
How do I get round this, as I believe the Update method works only for tables?
2. I'd like then to automatically allocate the DeliveryNoteNo rather than remember the last one used and type in a new one, ie use a lookup that finds the last number allocated and add 1 to it.
3. As a refinement it would be useful to be able to select the subform line items ready for delivery (with a checkbox) and apply the DeliveryNoteNo to just these.
Your help is much appreciated as ever.
Have main form frmCustomers containing customer details and a subform with items tready for delivery to them, as a datasheet.
I want to enter a DeliveryNoteNo in the main form and apply it to items appearing in the subform. The subform derives from a query based on tables JobItemsReadyForDespatch and Customers.
Three parts to the question
1. I've created DeliveryNoteNo as an unbound textbox and added this After Update procedure
Private Sub DeliveryNoteNo_AfterUpdate()
Dim strSQL2 As String
strSQL2 = "Update JobItemsReadyForDespatch Set DeliveryNoteNo = [forms]![frmCustomers]![DeliveryNoteNo] where Customer='" & Me.Customer & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL2
DoCmd.SetWarnings True
End Sub
This applies the DeliveryNoteNo okay but to all records, not just the chosen customer's. I think the problem is the Where bit, since the Customer field isn't in table JobItemsReadyForDespatch but in the query.
How do I get round this, as I believe the Update method works only for tables?
2. I'd like then to automatically allocate the DeliveryNoteNo rather than remember the last one used and type in a new one, ie use a lookup that finds the last number allocated and add 1 to it.
3. As a refinement it would be useful to be able to select the subform line items ready for delivery (with a checkbox) and apply the DeliveryNoteNo to just these.
Your help is much appreciated as ever.