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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a count based on multiple criteia

Status
Not open for further replies.

ClassyLinks

Programmer
Sep 13, 2001
8
CA
Hey all.

This is driving me CRAZY!.

I'm attempting to count the number of records in a table that meet my criteria. I can get it to work if I only use one condition....but not more.

This works:

JulLLContactStay = conn.execute("SELECT count(LLID) FROM tblLLContact WHERE LLARea = 1 ")


BUT...when I attempt to also qualify it with a date condition....I want the ContactDate to be anytime in July/2002 it dies with an Invalid Procedure call.

Can anyone tell me how to add the date criteria?

I've tried every combination of instr(ContactDate) I can think of.

TIA!!


Notes:

**ContactDate is a Date/Time Field in the db set to Long Date format
**DB is Access2000
ClassyLinks :cool:
 
("SELECT count(LLID) FROM tblLLContact WHERE LLARea = 1 " and mydate between #" & startDate & "# and #" & endDate &"#")

you will need to put the hash marks (#) around the date for access date queries
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Hi and thanks for responding.

I'm not really looking for the BETWEEN function, if I can avoid it... Because I write this query for every month of the year and would need to do the start/end dates for each month....

I'll give your suggestions of the # a whirl and see what I can come up with. ClassyLinks :cool:
 
I think I did it!

conn.execute("SELECT count(LLID) FROM tblLLContact WHERE LLARea = 1 AND ContactDate CONTAINS '*July*2002'")

Seems to work!

Thanks for your help! ClassyLinks :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top