foxpc123
asked on
Dcount on multiple criteria
I am using the following code to determine if a record exists in table tmpJobs were week = thisweek and CustomerID = thisCustomerID
Dim thisCompany As IntegerDim thisweek As Integer
JobCount = DCount("[Week]", "tmpJobs", "[week] =" & thisweek And "[CompanyID]=" & thisCompany)
I am getting data mismatch.
If I seperate the line into two
JobCount = DCount("[Week]", "tmpJobs", "[week] =" & thisweek)NoJobs = DCount("[Week]", "tmpJobs", "[CompanyID]=" & thisCompany)
this works and JobCount and NoJobs = 1
Why can't I have them on same line to only count when both criteria are met.
"[week] =" & thisweek & "And [CompanyID]=" & thisCompany
Add some spaces:
"[week] = " & thisweek & " And [CompanyID] = " & thisCompany
"[week] = " & thisweek & " And [CompanyID] = " & thisCompany
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JobCount = DCount("[Week]", "tmpJobs", "[week] ='" & thisweek And "'[CompanyID]='" & thisCompany & "'")
JobCount = DCount("[Week]", "tmpJobs", "[week] ='" & thisweek "' And [CompanyID]='" & thisCompany & "'")
ASKER
Thanks for quick responses