Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mixed Numeric & Text Criteria in DCount??? 2

Status
Not open for further replies.

alr0

Programmer
Joined
May 9, 2001
Messages
211
Location
US
Hi All,

When I step through the 3 lines of code below the first 2 run fine and make the correct assignment. The third line has a "type mismatch" error. (Third just combines criteria)

rsGtoHistory!gtosread = DCount("gtoimportid", "tblgtoimports", ("[gtodateimported] >= #" & dtRunBegin & "#"))

rsGtoHistory!gtosdonewoerror = DCount("gtoimportid", "tblgtoimports", ("[gtoerrors] = 'No application errors identified' "))

rsGtoHistory!gtosdonewoerror = DCount("gtoimportid", "tblgtoimports", ("[gtoerrors] = 'No application errors identified' ") And ("[gtodateimported] >= #" & dtRunBegin & "#"))

Is it illegal to combine criteria of different types with an "and"? I'm sure I have used multiple criteria before but I cannot remember if they were the same data type or not.

The only alternative I see is to create a recordset of each complex group and do a simple count on the total.

Thanks for your insights,

alr


_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Try replacing
("[gtoerrors] = 'No application errors identified' ") And ("[gtodateimported] >= #" & dtRunBegin & "#"))

with

("[gtoerrors] = 'No application errors identified' " And "[gtodateimported] >= #" & dtRunBegin & "#")

Basically removed the Parenthesis and moved the second criteria inside the Where portion of the dcount statment.

Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
rsGtoHistory!gtosdonewoerror = DCount("gtoimportid", "tblgtoimports", "gtoerrors='No application errors identified' AND gtodateimported>=#" & dtRunBegin & "#")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Andy,

I'm sorry, I must have missed something. I tried with only the DCount parens and with only one set around the where clause and I get the same type mismatch error both ways.

rsGtoHistory!gtosdonewoerror = DCount("gtoimportid", "tblgtoimports", ("[gtoerrors] = 'No application errors identified' " And "[gtodateimported] >= #" & dtRunBegin & "#"))

Since a commma separates the where clause I don't see how it is not in the where clause?

What am I missing.

Thanks,

alr

_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Have you tried my suggestion ?
 
OMG!

It works

Was it the square brackets? What's wrong with square brackets around field names and why would it run individualy but not combined?

The rough stuff I can handle but this...

Thanks,

alr

_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Was it the square brackets?
NO, but the double-quotes around the AND operator ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Oh I see.

They were 2 sets of double quotes one around each criterion but the effect was a set around the and.

Thanks,

alr

_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top