Dcount (1 Viewer)

DavidCon

Registered User.
Local time
Today, 04:49
Joined
Apr 14, 2011
Messages
23
Hi All,

This is driving me nuts as it should be simple to do but I must be missing the point somewhere along the way.

I have a form with some textboxes and I want to put a dcount in them depending on a couple of criteria.

In VBA on form load I have written the following code:

Staging2 is my table,
Queue is my field I want to count from

Code:
Text5 = DCount("Queue", "Staging2", "Queue = 'PS PO WF'")
Code:
Text7 = DCount("Queue", "Staging2", "Queue = 'PS Corp'")

Where am I going wrong please?
 

sneuberg

AWF VIP
Local time
Today, 04:49
Joined
Oct 17, 2014
Messages
3,506
I suggest testing it in the Immediate Window, i.e., paste in

Code:
?DCount("Queue", "Staging2", "Queue = 'PS PO WF'")

and hit return It might give you more information about what's wrong.

In case you don't know how to get to the Immediate Window
  1. Go to the VBE Editor. Click Visual Basic in the CREATE tab Macro & Code group or in some versions Alt F11 will get you there
  2. In the top Menu click on View and then Immediate Window or press Ctrl G
 

sneuberg

AWF VIP
Local time
Today, 04:49
Joined
Oct 17, 2014
Messages
3,506
Also the typical way to do this is to put it in the control source of the textbox proceeded by an equals sign, e.g.,

Code:
=DCount("Queue", "Staging2", "Queue = 'PS PO WF'")
 

Ranman256

Well-known member
Local time
Today, 07:49
Joined
Apr 9, 2015
Messages
4,337
and 'PS PO WF', is a single value in the field and NOT 3 values? (like an OR)
 

DavidCon

Registered User.
Local time
Today, 04:49
Joined
Apr 14, 2011
Messages
23
Thanks Guys, I figured it out..... It was working all along and I thought it was counting the whole table and not the criteria stated
 

Users who are viewing this thread

Top Bottom