Delete Query

syedadnan

Access Lover
Local time
, 01:42
Joined
Mar 27, 2013
Messages
315
I am having a query named "Just" with fields;

GR student GR number
MN month format from date showing as Feb-16
Voucher # showing latest voucher numbers issued

I want to make a delete query that to delete record in query "Just" with criteria if found same "MN" (means Found two or more records with FEB-16 or Mar-16 so on) in Same "GR" with highest "voucher #"

Example is attached
 

Attachments

I am having a query named "Just" with fields;

GR student GR number
MN month format from date showing as Feb-16
Voucher # showing latest voucher numbers issued

I want to make a delete query that to delete record in query "Just" with criteria if found same "MN" (means Found two or more records with FEB-16 or Mar-16 so on) in Same "GR" with highest "voucher #"

Example is attached
Sorry correct file is attached here
 

Attachments

Try the below:
Code:
DELETE VOUCHER.[VOUCHER #]
FROM VOUCHER
WHERE (((VOUCHER.[VOUCHER #]) In (SELECT  Max(VOUCHER.[VOUCHER #]) AS [MaxOfVOUCHER #]
FROM VOUCHER
GROUP BY Format([IssueDate],"mm\/yyyy"), VOUCHER.GR
HAVING (((Count(Format([IssueDate],"mm\/yyyy")))>1));)));
 

Users who are viewing this thread

Back
Top Bottom