J
Joan
Hi,
I am trying to update the field ,OnInvoice, of an adjustment record in the
Invoices table by
running an update query(qryUpdateAdjustments) via a button on the
InvoiceForm. I am having
trouble with the criteria of the Update query.
To explain further: On the InvoiceForm there is a button where the Invoice
is recorded
and several action queries run. One of which is called
qryUpdateAdjustments.
The purpose of this query is to look at the Invoice table and see if there
were a
any adjustments (Type = ADJ, or CR or DB) since the last invoice to this
particular customer( known as [Store]) was sent. If there were, then those
invoice
adjustments need to be applied to this invoice. (The Invoice [Type] can be
either
"INV" for Invoice or "ADJ", "CR" or "DB" for different types of adjustments.
Both
invoices and adjustments are recorded in the Invoices table. I should have
more aptly named this the Transactions table) The purpose of the
qryUpdateAdjustments query is to record the Invoice Number of the Invoice
that the adjustments are being applied to in the OnInvoice field of the
adjustment record . The adjustment record's Type is <> "INV" and the Store
field is the same as the one on the InvoiceForm. For this Type where [Type]
<> "INV" , DateSold is the date the Adjustment record is recorded. The date
in the adjustment record's DateSold field must be later than the DateSold of
the last invoice sent to that particular customer([Store]).
Hope I am explaining this so someone can understand what I am trying to do.
Following
is the SQL for qryUpdateAdjustments like I originally had it. As you can
see, I had the criteria for [DateSold] > [Forms]![InvoiceForm]![DateSold]-7.
This just updated any adjustments made in the last week. However, I thought
this did not accurately reflect what could happen. Invoices are sent out on
Mondays of every week to stores that have made purchases within that week.
However, a store may not make purchases every week, in which case an
Invoice may not be generated. This same store though may have a credit or
adjustment made in that time and it would not be reflected in the next
billing so I am trying to include all adjustments made since the last time
an Invoice was sent to that [Store].
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));
I so would appreciate any help with this. The last line of this SQL is where
I need help.
Joan
I am trying to update the field ,OnInvoice, of an adjustment record in the
Invoices table by
running an update query(qryUpdateAdjustments) via a button on the
InvoiceForm. I am having
trouble with the criteria of the Update query.
To explain further: On the InvoiceForm there is a button where the Invoice
is recorded
and several action queries run. One of which is called
qryUpdateAdjustments.
The purpose of this query is to look at the Invoice table and see if there
were a
any adjustments (Type = ADJ, or CR or DB) since the last invoice to this
particular customer( known as [Store]) was sent. If there were, then those
invoice
adjustments need to be applied to this invoice. (The Invoice [Type] can be
either
"INV" for Invoice or "ADJ", "CR" or "DB" for different types of adjustments.
Both
invoices and adjustments are recorded in the Invoices table. I should have
more aptly named this the Transactions table) The purpose of the
qryUpdateAdjustments query is to record the Invoice Number of the Invoice
that the adjustments are being applied to in the OnInvoice field of the
adjustment record . The adjustment record's Type is <> "INV" and the Store
field is the same as the one on the InvoiceForm. For this Type where [Type]
<> "INV" , DateSold is the date the Adjustment record is recorded. The date
in the adjustment record's DateSold field must be later than the DateSold of
the last invoice sent to that particular customer([Store]).
Hope I am explaining this so someone can understand what I am trying to do.
Following
is the SQL for qryUpdateAdjustments like I originally had it. As you can
see, I had the criteria for [DateSold] > [Forms]![InvoiceForm]![DateSold]-7.
This just updated any adjustments made in the last week. However, I thought
this did not accurately reflect what could happen. Invoices are sent out on
Mondays of every week to stores that have made purchases within that week.
However, a store may not make purchases every week, in which case an
Invoice may not be generated. This same store though may have a credit or
adjustment made in that time and it would not be reflected in the next
billing so I am trying to include all adjustments made since the last time
an Invoice was sent to that [Store].
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));
I so would appreciate any help with this. The last line of this SQL is where
I need help.
Joan