Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem using calculated expression within Dcount

Newbie
 
Join Date: Apr 2007
Posts: 10
#1: Apr 23 '07
Hello,

All help is appreciated, I'm struggling with the following.

Using Access 2003 (front end) connecting to Oracle 7 database (back end). I'm trying to create a query in access that will show how many instances of something happens.

Within the query I am using a calculated filed called "registered".The syntax is

Registered: DateDiff("w",[date_valid],[timestamp])

This returns a number 0.00, 1.00, 2.00 etc

Within the query or form (I've tried both), I'm trying to count the number times that 0.00 appears. I will then take this figure and use it to calculate the percentage. My problem is when using the dcount function to count the instances that something appears. I've tried the following

DCount("salary","Applications","registered=0.00")

This is where the errors start, I've also tried

DCount("salary","Applications","(DateDiff(""w"",[date_valid],[timestamp]))=1.00")

but this also errors with the same message. The error message always refers to "Start Date" which is one of the parameters of "date_valid" (the other being "End Date"). I've removed this parameter but it still asks for it.

Where am I going wrong?

msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,885
#2: Apr 24 '07

re: Problem using calculated expression within Dcount


In a new query based on the first query ...
Expand|Select|Wrap|Line Numbers
  1. Count0: Sum(IIf(Registered=0.00,1,0))
  2. Count1: Sum(IIf(Registered=1.00,1,0))
  3. Count2: Sum(IIf(Registered=2.00,1,0))
  4.  
Mary
Newbie
 
Join Date: Apr 2007
Posts: 10
#3: Apr 24 '07

re: Problem using calculated expression within Dcount


Quote:

Originally Posted by mmccarthy

In a new query based on the first query ...

Expand|Select|Wrap|Line Numbers
  1. Count0: Sum(IIf(Registered=0.00,1,0))
  2. Count1: Sum(IIf(Registered=1.00,1,0))
  3. Count2: Sum(IIf(Registered=2.00,1,0))
  4.  
Mary

Thanks for that, you have solved my problem, I didn't know about the IIF function.

Thanks again
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,885
#4: Apr 24 '07

re: Problem using calculated expression within Dcount


Quote:

Originally Posted by davidwelli

Thanks for that, you have solved my problem, I didn't know about the IIF function.

Thanks again

You're welcome.
Reply