A
A.S.
I've been trying the examples discussed in this forum, but no success.
There are two tables:
table (tbl_Expense) - ExpensePayee, CheckStatus, Submit Date
table (tb_Payee) - ExpensePayee, ID.
In the first query below (qryCheckStatus), only a group of IDs is used to
extract data from tbl_Expense. This query is working:
SELECT DISTINCT tbl_Payee.ID, tbl_Expense.ExpensePayee,
tbl_Expense.CheckStatus, tbl_Expense.[Submit Date]
FROM tbl_Expense INNER JOIN tbl_Payee ON tbl_Expense.ExpensePayee =
tbl_Payee.ExpensePayee
WHERE (((tbl_Payee.ID)=230 Or (tbl_Payee.ID)=268 Or (tbl_Payee.ID)=267 Or
(tbl_Payee.ID)=223 Or (tbl_Payee.ID)=265 Or (tbl_Payee.ID)=263 Or
(tbl_Payee.ID)=116 Or (tbl_Payee.ID)=269 Or (tbl_Payee.ID)=235 Or
(tbl_Payee.ID)=270 Or (tbl_Payee.ID)=266 Or (tbl_Payee.ID)=264 Or
(tbl_Payee.ID)=276))
ORDER BY tbl_Expense.ExpensePayee;
Second query below (qryCheckStatus2) uses Max to find the latest Submit
Date, but it shows ALL records instead:
SELECT DISTINCT qryCheckStatus.ExpensePayee, qryCheckStatus.CheckStatus,
Max(qryCheckStatus.[Submit Date]) AS [Submit DateOfMax]
FROM qryCheckStatus
GROUP BY qryCheckStatus.ExpensePayee, qryCheckStatus.CheckStatus
ORDER BY qryCheckStatus.ExpensePayee;
So I wrote another query below to find only one record for each Payee, but
it gives me the same reqult as the 2nd query above:
SELECT DISTINCTROW qryCheckStatus.ExpensePayee, qryCheckStatus.CheckStatus,
qryCheckStatus2.[Submit DateOfMax]
FROM qryCheckStatus INNER JOIN qryCheckStatus2 ON
(qryCheckStatus2.ExpensePayee = qryCheckStatus.ExpensePayee) AND
(qryCheckStatus.[Submit Date] = qryCheckStatus2.[Submit DateOfMax])
ORDER BY qryCheckStatus.ExpensePayee;
Could anyone show me way to find only the record with the latest Submit Date?
Thank you,
There are two tables:
table (tbl_Expense) - ExpensePayee, CheckStatus, Submit Date
table (tb_Payee) - ExpensePayee, ID.
In the first query below (qryCheckStatus), only a group of IDs is used to
extract data from tbl_Expense. This query is working:
SELECT DISTINCT tbl_Payee.ID, tbl_Expense.ExpensePayee,
tbl_Expense.CheckStatus, tbl_Expense.[Submit Date]
FROM tbl_Expense INNER JOIN tbl_Payee ON tbl_Expense.ExpensePayee =
tbl_Payee.ExpensePayee
WHERE (((tbl_Payee.ID)=230 Or (tbl_Payee.ID)=268 Or (tbl_Payee.ID)=267 Or
(tbl_Payee.ID)=223 Or (tbl_Payee.ID)=265 Or (tbl_Payee.ID)=263 Or
(tbl_Payee.ID)=116 Or (tbl_Payee.ID)=269 Or (tbl_Payee.ID)=235 Or
(tbl_Payee.ID)=270 Or (tbl_Payee.ID)=266 Or (tbl_Payee.ID)=264 Or
(tbl_Payee.ID)=276))
ORDER BY tbl_Expense.ExpensePayee;
Second query below (qryCheckStatus2) uses Max to find the latest Submit
Date, but it shows ALL records instead:
SELECT DISTINCT qryCheckStatus.ExpensePayee, qryCheckStatus.CheckStatus,
Max(qryCheckStatus.[Submit Date]) AS [Submit DateOfMax]
FROM qryCheckStatus
GROUP BY qryCheckStatus.ExpensePayee, qryCheckStatus.CheckStatus
ORDER BY qryCheckStatus.ExpensePayee;
So I wrote another query below to find only one record for each Payee, but
it gives me the same reqult as the 2nd query above:
SELECT DISTINCTROW qryCheckStatus.ExpensePayee, qryCheckStatus.CheckStatus,
qryCheckStatus2.[Submit DateOfMax]
FROM qryCheckStatus INNER JOIN qryCheckStatus2 ON
(qryCheckStatus2.ExpensePayee = qryCheckStatus.ExpensePayee) AND
(qryCheckStatus.[Submit Date] = qryCheckStatus2.[Submit DateOfMax])
ORDER BY qryCheckStatus.ExpensePayee;
Could anyone show me way to find only the record with the latest Submit Date?
Thank you,