J
Joan
Hi,
I am not sure how to resolve the following problem. I have an Invoice
form where when the user enters a store code on the main form, the dogs
that are to be invoiced automatically appear in a subform. This subform is
based on a query that has a limiting criteria of when [FinalStore] Is Null.
[FinalStore]
acts as a switch to indicate whether the dog has been invoiced (sold) or
available
for sale. The problem enters when the user clicks the "Record Invoice"
button. This
button runs several action queries.
The first is an append query(SalesAppendQuery) which appends the Invoice
Number from the main form and the Dog Number and Salesprice for each dog
from the subform to the Sales table.
PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text ( 255 );
INSERT INTO Sales ( [Dog Number], InvSalePrice, [Invoice Number] )
SELECT qryInvoiceSubform2.[Dog Number], qryInvoiceSubform2.SalesPrice,
Invoices.[Invoice Number]
FROM Invoices, qryInvoiceSubform2
WHERE (((Invoices.[Invoice
Number])=[Forms]![InvoiceForm]![txtInvoiceNumber]) AND
((qryInvoiceSubform2.Store)=[Forms]![InvoiceForm]![StoreCode]));
The second query is an update query which is supposed to update the
FinalStore field to the value of txtStore in the subform.
UPDATE Dogs SET Dogs.FinalStore = Forms!InvoiceForm!InvoiceSubform!txtstore
WHERE (((Dogs.[Dog Number])=[Forms]![InvoiceForm]![InvoiceSubform]![Dog
Number]));
When the user clicks the "Record Invoice" button, the first append query
runs fine, but the
second update query only puts the txtstore value in one record and not the
others. For instance,
dogs with Dog Numbers: 1076, 1026 and 907 are all listed on the subform,
but the update only
works on the dog #1076 record and not the other two. FinalStore is blank for
both dog records with
Dog Number 1026 and 907. What would cause this to happen? I placed a
Me.Recalc in my code after the
first query runs. See code below.
Thanks ahead for any help.
Joan
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
........
I am not sure how to resolve the following problem. I have an Invoice
form where when the user enters a store code on the main form, the dogs
that are to be invoiced automatically appear in a subform. This subform is
based on a query that has a limiting criteria of when [FinalStore] Is Null.
[FinalStore]
acts as a switch to indicate whether the dog has been invoiced (sold) or
available
for sale. The problem enters when the user clicks the "Record Invoice"
button. This
button runs several action queries.
The first is an append query(SalesAppendQuery) which appends the Invoice
Number from the main form and the Dog Number and Salesprice for each dog
from the subform to the Sales table.
PARAMETERS [Forms]![InvoiceForm]![StoreCode] Text ( 255 );
INSERT INTO Sales ( [Dog Number], InvSalePrice, [Invoice Number] )
SELECT qryInvoiceSubform2.[Dog Number], qryInvoiceSubform2.SalesPrice,
Invoices.[Invoice Number]
FROM Invoices, qryInvoiceSubform2
WHERE (((Invoices.[Invoice
Number])=[Forms]![InvoiceForm]![txtInvoiceNumber]) AND
((qryInvoiceSubform2.Store)=[Forms]![InvoiceForm]![StoreCode]));
The second query is an update query which is supposed to update the
FinalStore field to the value of txtStore in the subform.
UPDATE Dogs SET Dogs.FinalStore = Forms!InvoiceForm!InvoiceSubform!txtstore
WHERE (((Dogs.[Dog Number])=[Forms]![InvoiceForm]![InvoiceSubform]![Dog
Number]));
When the user clicks the "Record Invoice" button, the first append query
runs fine, but the
second update query only puts the txtstore value in one record and not the
others. For instance,
dogs with Dog Numbers: 1076, 1026 and 907 are all listed on the subform,
but the update only
works on the dog #1076 record and not the other two. FinalStore is blank for
both dog records with
Dog Number 1026 and 907. What would cause this to happen? I placed a
Me.Recalc in my code after the
first query runs. See code below.
Thanks ahead for any help.
Joan
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
........