Solved DCount and Like (2 Viewers)

JithuAccess

Member
Local time
Today, 13:15
Joined
Mar 3, 2020
Messages
297
Hi,

This is my code to find the total number of Denials in an Application and I want to use Like

Code:
=DCount("[strID]","[tblMaster Table]","[datDate Application Received] between DateSerial(Year(Date())-1,4,1) And DateSerial(Year(Date())+0,3,31) And [strStatus of Application] like "*" &  'Denied' & "*"")

But I am getting "#Type!" Error message. Could you please let me know what I have done wrong?

Thanks
 

GPGeorge

Grover Park George
Local time
Today, 12:15
Joined
Nov 25, 2004
Messages
1,873
What happens if you change the concatenation?
=DCount("[strID]","[tblMaster Table]","[datDate Application Received] between DateSerial(Year(Date())-1,4,1)
And DateSerial(Year(Date())+0,3,31)
And [strStatus of Application] like '*Denied*'")

====
too slow....
 

SHANEMAC51

Active member
Local time
Today, 22:15
Joined
Jan 28, 2022
Messages
310
But I am getting "#Type!" Error message. Could you please let me know what I have done wrong?
try this, splitting into substrings for clarity, for the forum

Code:
=DCount("[strID]",
"[tblMaster Table]",
"[datDate Application Received]
 between DateSerial(Year(Date())-1,4,1)
 And DateSerial(Year(Date())+0,3,31)
 And [strStatus of Application] like '*Denied'*")
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:15
Joined
Feb 19, 2002
Messages
43,280
You should assign a group to your Status codes. That way you can pick by the group and not have to use like. Line is extremely inefficient since it almost always forces a full table scan. So, the larger your table, the slower the query as it reads RBAR (row by agonizing row) instead of using indexes to whittle down the selected recordset.
 

Users who are viewing this thread

Top Bottom