J
Joan
Hi,
I have a click event on an Invoice form where I want to run several action
queries. The problem is that the click event runs the first action query
but not the others. Why is it doing this??
Below is the code behind the click event:
Private Sub RecordInvoice_Click()
On Error GoTo Err_RecordInvoice_Click
Dim stDocName As String
Dim stQueryName As String
Dim FirstUpdate As String
FirstUpdate = "SalesRetUpdateQuery"
DoCmd.SetWarnings False
DoCmd.OpenQuery FirstUpdate, acViewNormal, acEdit
DoCmd.SetWarnings True
stDocName = "SalesAppendQuery"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acViewNormal, acEdit
DoCmd.SetWarnings True
stQueryName = "qryUpdateAdjustments"
DoCmd.SetWarnings False
DoCmd.OpenQuery stQueryName, acViewNormal, acEdit
DoCmd.SetWarnings True
Me.cboType.SetFocus
Me.RecordInvoice.Enabled = False
Me.Recalc
Exit_RecordInvoice_Click:
Exit Sub
Err_RecordInvoice_Click:
MsgBox Err.Description
Resume Exit_RecordInvoice_Click
End Sub
Below are the SQLs for the action queries:
SalesRetUpdateQuery: UPDATE Sales SET Sales.ReturnedSaleDate =
Forms!InvoiceForm!DateSold, Sales.ReturnedInvoice =
Forms!InvoiceForm!txtInvoiceNumber
WHERE (((Sales.Returned)="Y") AND ((Sales.[Dog
Number])=[Forms]![InvoiceForm]![InvoiceSubform]![Dog Number]));
SalesAppendQuery: PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text (
255 );
INSERT INTO Sales ( [Dog Number], [Invoice Number] )
SELECT qryInvoiceSubform2.[Dog Number], Invoices.[Invoice Number]
FROM Invoices, qryInvoiceSubform2
WHERE (((Invoices.[Invoice
Number])=[Forms]![InvoiceForm]![txtInvoiceNumber]) AND
((qryInvoiceSubform2.Store)=[Forms]![InvoiceForm]![StoreCode]));
qryUpdateAdjustments: PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text
( 255 ), [Forms]![InvoiceForm]![DateSold] DateTime;
UPDATE Invoices SET Invoices.OnInvoice = Forms!InvoiceForm!txtInvoiceNumber
WHERE (((Invoices.Type)<>"INV") AND
((Invoices.Store)=[Forms]![InvoiceForm]![StoreCode]) AND
((Invoices.DateSold)>[Forms]![InvoiceForm]![DateSold]-7));
SalesRetUpdateQuery updates Sales so that if a returned dog is sold again,
the sale date and Invoice Number of the resale is entered in
Sales.ReturnedSaleDate and Sales.ReturnedInvoice of the first sale record.
SalesAppendQuery adds the Invoice Number from the InvoiceForm and the Dog
Number from the InvoiceSubform to the Sales table.
qryUpdateAdjustments records the Invoice Number of the invoice that shows a
credit or adjustment in the OnInvoice field of the credit or adjustment
transaction record.
Thanks ahead of time for any assistance in figuring this out.
Joan
I have a click event on an Invoice form where I want to run several action
queries. The problem is that the click event runs the first action query
but not the others. Why is it doing this??
Below is the code behind the click event:
Private Sub RecordInvoice_Click()
On Error GoTo Err_RecordInvoice_Click
Dim stDocName As String
Dim stQueryName As String
Dim FirstUpdate As String
FirstUpdate = "SalesRetUpdateQuery"
DoCmd.SetWarnings False
DoCmd.OpenQuery FirstUpdate, acViewNormal, acEdit
DoCmd.SetWarnings True
stDocName = "SalesAppendQuery"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acViewNormal, acEdit
DoCmd.SetWarnings True
stQueryName = "qryUpdateAdjustments"
DoCmd.SetWarnings False
DoCmd.OpenQuery stQueryName, acViewNormal, acEdit
DoCmd.SetWarnings True
Me.cboType.SetFocus
Me.RecordInvoice.Enabled = False
Me.Recalc
Exit_RecordInvoice_Click:
Exit Sub
Err_RecordInvoice_Click:
MsgBox Err.Description
Resume Exit_RecordInvoice_Click
End Sub
Below are the SQLs for the action queries:
SalesRetUpdateQuery: UPDATE Sales SET Sales.ReturnedSaleDate =
Forms!InvoiceForm!DateSold, Sales.ReturnedInvoice =
Forms!InvoiceForm!txtInvoiceNumber
WHERE (((Sales.Returned)="Y") AND ((Sales.[Dog
Number])=[Forms]![InvoiceForm]![InvoiceSubform]![Dog Number]));
SalesAppendQuery: PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text (
255 );
INSERT INTO Sales ( [Dog Number], [Invoice Number] )
SELECT qryInvoiceSubform2.[Dog Number], Invoices.[Invoice Number]
FROM Invoices, qryInvoiceSubform2
WHERE (((Invoices.[Invoice
Number])=[Forms]![InvoiceForm]![txtInvoiceNumber]) AND
((qryInvoiceSubform2.Store)=[Forms]![InvoiceForm]![StoreCode]));
qryUpdateAdjustments: PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text
( 255 ), [Forms]![InvoiceForm]![DateSold] DateTime;
UPDATE Invoices SET Invoices.OnInvoice = Forms!InvoiceForm!txtInvoiceNumber
WHERE (((Invoices.Type)<>"INV") AND
((Invoices.Store)=[Forms]![InvoiceForm]![StoreCode]) AND
((Invoices.DateSold)>[Forms]![InvoiceForm]![DateSold]-7));
SalesRetUpdateQuery updates Sales so that if a returned dog is sold again,
the sale date and Invoice Number of the resale is entered in
Sales.ReturnedSaleDate and Sales.ReturnedInvoice of the first sale record.
SalesAppendQuery adds the Invoice Number from the InvoiceForm and the Dog
Number from the InvoiceSubform to the Sales table.
qryUpdateAdjustments records the Invoice Number of the invoice that shows a
credit or adjustment in the OnInvoice field of the credit or adjustment
transaction record.
Thanks ahead of time for any assistance in figuring this out.
Joan