Sorry -- found some typos:
SELECT VendorInv.EnterDate, Vendor.VendorID, Vendor.VendorName,
VendorInv.InvoiceID, Vendor.VendorCtry, Vendor.VendorCostCenter,
VendorInv.PerDate, VendorInv.InvDesc, VendorInv.InvAmt,
VendorInv.InvoiceCode, 1 As SortOrder
FROM Vendor INNER JOIN VendorInv ON Vendor.VendorID = VendorInv.VendorID
WHERE (((VendorInv.EnterDate) Between
[Forms]![fdlgAskForDatesAndCity2]![txtStartDate] And
[Forms]![fdlgAskForDatesAndCity2]![txtEndDate]) AND ((Vendor.VendorCtry)
Like
[Forms]![fdlgAskForDatesAndCity2]![cboCity] & "*"))
UNION ALL
SELECT Null, Null, Null, Null, Null, Null, Null, Null,
Sum(TT.InvAmt) AS SF3, Null, 2 AS SortOrder
FROM Vendor AS T INNER JOIN VendorInv AS TT ON T.VendorID = TT.VendorID
WHERE (((TT.EnterDate) Between
[Forms]![fdlgAskForDatesAndCity2]![txtStartDate] And
[Forms]![fdlgAskForDatesAndCity2]![txtEndDate]) AND ((T.VendorCtry) Like
[Forms]![fdlgAskForDatesAndCity2]![cboCity] & "*"))
ORDER BY SortOrder, VendorInv.EnterDate;
--
Ken Snell
<MS ACCESS MVP>
Thanks Ken,
For some reason, i run the query and receive TT.VendorInv.InvAmt
prompt. I
guess this is something that I need to work through and i want to thank
you
for the excellent support.
:
This should do what you seek:
SELECT VendorInv.EnterDate, Vendor.VendorID, Vendor.VendorName,
VendorInv.InvoiceID, Vendor.VendorCtry, Vendor.VendorCostCenter,
VendorInv.PerDate, VendorInv.InvDesc, VendorInv.InvAmt,
VendorInv.InvoiceCode
FROM Vendor INNER JOIN VendorInv ON Vendor.VendorID =
VendorInv.VendorID
WHERE (((VendorInv.EnterDate) Between
[Forms]![fdlgAskForDatesAndCity2]![txtStartDate] And
[Forms]![fdlgAskForDatesAndCity2]![txtEndDate]) AND
((Vendor.VendorCtry)
Like
[Forms]![fdlgAskForDatesAndCity2]![cboCity] & "*"))
UNION ALL
SELECT Null, Null, Null, Null, Null, Null, Null, Null,
Sum(TT.VendorInv.InvAmt) AS SF3, 2 AS SortOrder
FROM Vendor AS T INNER JOIN VendorInv AS TT ON T.VendorID =
TT.VendorID
WHERE (((TT.EnterDate) Between
[Forms]![fdlgAskForDatesAndCity2]![txtStartDate] And
[Forms]![fdlgAskForDatesAndCity2]![txtEndDate]) AND ((T.VendorCtry)
Like
[Forms]![fdlgAskForDatesAndCity2]![cboCity] & "*"))
ORDER BY VendorInv.EnterDate;
--
Ken Snell
<MS ACCESS MVP>
Hello Ken,
In order to avoid several emails, i thought it best to show the SQL
view:
SELECT VendorInv.EnterDate, Vendor.VendorID, Vendor.VendorName,
VendorInv.InvoiceID, Vendor.VendorCtry, Vendor.VendorCostCenter,
VendorInv.PerDate, VendorInv.InvDesc, VendorInv.InvAmt,
VendorInv.InvoiceCode
FROM Vendor INNER JOIN VendorInv ON Vendor.VendorID =
VendorInv.VendorID
WHERE (((VendorInv.EnterDate) Between
[Forms]![fdlgAskForDatesAndCity2]![txtStartDate] And
[Forms]![fdlgAskForDatesAndCity2]![txtEndDate]) AND
((Vendor.VendorCtry)
Like
[Forms]![fdlgAskForDatesAndCity2]![cboCity] & "*"))
ORDER BY VendorInv.EnterDate;
The VendorInv.InvAmt is the field that i would like to have totaled
automatically in excell. There are 8 fields in front of InvAmt field
so
would
i apply your answer to the eight fields before it?
:
You want to show the total of a column at the bottom of the column?
If
yes,
you'd need to create a union query and export that query (following
shows
how you'd do it if you wanted to sum the third column -- it uses a
sorting
field to ensure that the total is the last thing exported; if you
don't
want
that extra column, you'd need to identify some way to add
information
to
the
second subquery so that it's recod would sort last in the export):
SELECT T.Field1, T.Field2, T.Field3, 1 AS SortOrder
FROM TableName AS T
UNION ALL
SELECT Null, Null, Sum(TT.Field3) AS SF3, 2 AS SortOrder
FROM TableName AS TT
ORDER BY SortOrder;
--
Ken Snell
<MS ACCESS MVP>
Thanks Ken,
I have worked on it and date parameters are now are fine. There
is a
function to export to excell, do you know if on exporting to
excell,
is
there
away to set up the source query so there will be a total on one
column?
:
Tom's taking well-deserved vacation for a few days, so let me
see
if I
can
assist.
In Tom's sample database, the record source query for the
"fdlgAskForDatesAndCity2" form is "qryShowMinAndMaxOrderDate".
Did
you
change this to the query that you want to use -- which I assume
is
"querytester1"?
--
Ken Snell
<MS ACCESS MVP>
Hello Tom,
I imported my tables and applied one query called
querytester1.
When
i
use
the form fdlgAskfor Datesand City2, my query will run but
display
all
records
since i inserted my query in this part of the code. How do get
the
form
to
use querytester1 and have the dates parameter apply to it?
:
Hi JK,
You're welcome. If you get stuck, please post back.
Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
:
Tom, This download is pretty cool. I am not great in VB but
i
will
try
to
modify the forms you have in this download to my
application.
If
you
dont
mind, i may need your help in the event i cant through it
but
thank
you
for
opening my thoughts on this matter.
hymadyson, thanks for the reply as well!