J
Joan
Could someone tell me what I need to do when I am running 3 action queries
in the OnClick event procedure of a button on a form ( InvoiceForm)? In
particular when I first run an append query followed by an update query.
When I run my code below, the first query, an append query works just fine,
but the second query, an update query doesn't work. Correction, the update
query works on my computer which has Access 2002 but not on the customer's
computer which has Access 2003. Nothing else as far a I can tell is
dissimiliar between the two. Cannot find anything in the literature on
Access 2003 which would indicate I need to code this differently so am
puzzled by why it won't work.
Private Sub RecordInvoice_Click()
On Error GoTo Err_RecordInvoice_Click
Dim stDocName As String
Dim stQueryName As String
Dim FirstUpdate As String
'Run action query to append Dog Numbers of dogs on invoice, the _
Invoice Number of this invoice and the SalesPrice for each dog on the _
invoice to the Sales table.
stDocName = "SalesAppendQuery"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acViewNormal, acEdit
DoCmd.SetWarnings True
Me.Recalc
'For dogs that have been sold on this invoice, append the StoreCode
' from this form to the dog's FinalStore field.
FirstUpdate = "UpdateFinalStoreRetDog"
DoCmd.SetWarnings False
DoCmd.OpenQuery FirstUpdate, acViewNormal, acEdit
DoCmd.SetWarnings True
Me.Recalc
' action query to enter Invoice Number in OnInvoice field of any
adjustments records made _
since the last invoice to the store.
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
The query, UpdateFinalStoreRetDog, is supposed to put the Store that the dog
is sold to in the FinalStore field, which will in effect take the dog record
off of the inventory screen because of criteria set in the inventory
screen's underlying query. The dog's record however does not come off of
the inventory screen when the dog is invoiced like it is supposed to. Below
is the SQL for the update query which will not work in Access 2003.
UPDATE Dogs SET Dogs.FinalStore = Forms!InvoiceForm!StoreCode
WHERE (((Dogs.[Dog Number])=[Forms]![InvoiceForm]![InvoiceSubform]![Dog
Number]));
Here is the SQL for the append query which precedes the update query:
PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text ( 255 );
INSERT INTO Sales ( [Dog Number], InvSalePrice, [Invoice Number] )
SELECT qryInvoiceSubform2.[Dog Number], qryInvoiceSubform2.SalesPrice,
Invoices.[Invoice Number]
FROM qryInvoiceSubform2, Invoices
WHERE (((Invoices.[Invoice
Number])=[Forms]![InvoiceForm]![txtInvoiceNumber]) AND
((qryInvoiceSubform2.Store)=[Forms]![InvoiceForm]![StoreCode]));
I would so appreciate any help with this. It is driving me bonkers.
Joan
in the OnClick event procedure of a button on a form ( InvoiceForm)? In
particular when I first run an append query followed by an update query.
When I run my code below, the first query, an append query works just fine,
but the second query, an update query doesn't work. Correction, the update
query works on my computer which has Access 2002 but not on the customer's
computer which has Access 2003. Nothing else as far a I can tell is
dissimiliar between the two. Cannot find anything in the literature on
Access 2003 which would indicate I need to code this differently so am
puzzled by why it won't work.
Private Sub RecordInvoice_Click()
On Error GoTo Err_RecordInvoice_Click
Dim stDocName As String
Dim stQueryName As String
Dim FirstUpdate As String
'Run action query to append Dog Numbers of dogs on invoice, the _
Invoice Number of this invoice and the SalesPrice for each dog on the _
invoice to the Sales table.
stDocName = "SalesAppendQuery"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acViewNormal, acEdit
DoCmd.SetWarnings True
Me.Recalc
'For dogs that have been sold on this invoice, append the StoreCode
' from this form to the dog's FinalStore field.
FirstUpdate = "UpdateFinalStoreRetDog"
DoCmd.SetWarnings False
DoCmd.OpenQuery FirstUpdate, acViewNormal, acEdit
DoCmd.SetWarnings True
Me.Recalc
' action query to enter Invoice Number in OnInvoice field of any
adjustments records made _
since the last invoice to the store.
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
The query, UpdateFinalStoreRetDog, is supposed to put the Store that the dog
is sold to in the FinalStore field, which will in effect take the dog record
off of the inventory screen because of criteria set in the inventory
screen's underlying query. The dog's record however does not come off of
the inventory screen when the dog is invoiced like it is supposed to. Below
is the SQL for the update query which will not work in Access 2003.
UPDATE Dogs SET Dogs.FinalStore = Forms!InvoiceForm!StoreCode
WHERE (((Dogs.[Dog Number])=[Forms]![InvoiceForm]![InvoiceSubform]![Dog
Number]));
Here is the SQL for the append query which precedes the update query:
PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text ( 255 );
INSERT INTO Sales ( [Dog Number], InvSalePrice, [Invoice Number] )
SELECT qryInvoiceSubform2.[Dog Number], qryInvoiceSubform2.SalesPrice,
Invoices.[Invoice Number]
FROM qryInvoiceSubform2, Invoices
WHERE (((Invoices.[Invoice
Number])=[Forms]![InvoiceForm]![txtInvoiceNumber]) AND
((qryInvoiceSubform2.Store)=[Forms]![InvoiceForm]![StoreCode]));
I would so appreciate any help with this. It is driving me bonkers.
Joan