Solved Form to show totals using dCount with multliple criteria (1 Viewer)

kengooch

Member
Local time
Today, 09:10
Joined
Feb 29, 2012
Messages
137
I have a form that shows totals in several unbound text boxes. For example in my tMwvEvnt Table I only want to count records whose tEvntType =1 so I use =DCount("*","tMwvEvnt","tEvntType = 1") and it works great.

But I also need to count the records where "tEvntType" = 1 and "tFacility" = 1

I tried several things similar to this...
=DCount("*","tMwvEvnt","[tFacility] = 1 & and & "tMwvEvnt","[tEvntType] = 1")

But I keep getting a syntax error.

Any help would be appreciated.
 

bob fitz

AWF VIP
Local time
Today, 17:10
Joined
May 23, 2011
Messages
4,719
Try:
=DCount("*","tMwvEvnt","[tFacility] = 1 AND [tEvntType] = 1")
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:10
Joined
Sep 21, 2011
Messages
14,257
If more than one criteria, I tend to put it all into a string variable and the debug.print it. That way you can see your errors?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:10
Joined
Feb 19, 2002
Messages
43,257
Rather than hard-coding all the values, use a totals query and display it in a subform or listbox. It will be far more efficient and not require constant maintenance as the data changes.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:10
Joined
Feb 19, 2002
Messages
43,257
Hope you don't have to add a new facility or a new event type.
 

bob fitz

AWF VIP
Local time
Today, 17:10
Joined
May 23, 2011
Messages
4,719
That worked perfect!! thanks so much
Glad it worked for you.

I would advise you to give consideration to Pat's comments in post #4. I've always found her advice to be worth its weight in gold.
 

Users who are viewing this thread

Top Bottom