Problem with "count" function

arunakumari02

Registered User.
Local time
Today, 15:36
Joined
Jun 2, 2008
Messages
91
Dim X as integer

Code:
X = Val("SELECT COUNT(DISTINCT ID) FROM tblResource GROUP BY ID HAVING ProjectID =" & labID)

I have a problem with this query. This should return 3 but return 0.

Any help
 
why don't you use a dcount function instead?

X = dcount([ID], "tblResource", "ProjectID = '" & labID &"'")

should that be me.labID?
 
I have to count only unquie values in the table where Dcount do not work.

Any help
 
lol.... duh..... look at the sql :p

sorry, at work, doing about 5 things at once :p
 
Dim X as integer

Code:
X = Val("SELECT COUNT(DISTINCT ID) FROM tblResource GROUP BY ID HAVING ProjectID =" & labID)

I have a problem with this query. This should return 3 but return 0.

Any help


Try breaking the query down in pieces

SELECT DISTINCT ID FROM tblResource;

SELECT DISTINCT ID FROM tblResource WHERE ProjectID = me.labID;

SELECT COUNT(DISTINCT ID) FROM tblResource GROUP BY ID HAVING ProjectID = me.labID;

See if each sub query adds up right. Perhaps you will find a weakness to build up.
 
I still have a problem.

The statement generates an error:

Code:
int X = ECount("[ID]", "tblResource", "[ProjectID] =" & labID)

The Ecount should generate unique values if ID from the tblResource where projectId = labID

Any help
 

Users who are viewing this thread

Back
Top Bottom