Solved

Access 2010 Trying to find duplicate statements in a month

Posted on 2014-03-10
6
333 Views
Last Modified: 2014-03-10
I am trying to find duplicate statements that are entered in 1 month but the data entry may be off a day.  
Example: Statement Dates are 01/31/14, 02/28/14, 02/28/14, 03/30/14
          or  Statement Dates are 01/31/14, 02/28/14, 03/05/14, 03/30/14

I should only have 1 statement a month.  I wanted to try to create a field to convert the statement date to Month format, then look for duplicates in the month.

Fields:  
AccountID (Account Number)
StatementDate (Statement Date)

I tried:
Expr1: Format([StatementDate],"mmm")
0
Comment
Question by:NNiicckk
  • 3
  • 3
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39918567
try this query

select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
where Count(Format([StatementDate],"yyyymm"))>1
Group by AccountID,Count(Format([StatementDate],"yyyymm"))


or

select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
Group by AccountID,Count(Format([StatementDate],"yyyymm"))
having Count(Format([StatementDate],"yyyymm"))>1
0
 

Author Comment

by:NNiicckk
ID: 39918680
It says I cannot have a aggregate funtion in GROUP BY clause (Count(Format([StatementDate],"yyyymm")))
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39918711
oops sorry


select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
where Count(Format([StatementDate],"yyyymm"))>1
Group by AccountID, Format([StatementDate],"yyyymm")


or

select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Count(Format([StatementDate],"yyyymm")) As expr2
from tableName
Group by AccountID, Format([StatementDate],"yyyymm")
having Count(Format([StatementDate],"yyyymm"))>1
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:NNiicckk
ID: 39918850
The first one had "Cannot have aggregate function in WHERE clause (Count(Format([StatementDate],"yyyymm"))>1

The second one worked, thanks.

The results give me the # of statements in expr1 and expr2:

AccountID      Expr1      Expr2
125555                  3               3
567891               2          2


Is there a way to show the Month duplicated or should I just hide 1 of the fields?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39918875
try


select AccountID,Count(Format([StatementDate],"yyyymm")) As Expr1,Format([StatementDate],"yyyymm") As expr2
from tableName
Group by AccountID, Format([StatementDate],"yyyymm")
having Count(Format([StatementDate],"yyyymm"))>1
0
 

Author Comment

by:NNiicckk
ID: 39919087
That works, thanks again
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question