Dcount

DavidCon

Registered User.
Local time
Today, 13:40
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?
 
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
 
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'")
 
and 'PS PO WF', is a single value in the field and NOT 3 values? (like an OR)
 
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

Back
Top Bottom