Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access 2010 Trying to find duplicate statements in a month

Posted on 2014-03-10
6
334 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

792 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