dbTalk Databases Forums  

DCount WHERE Clause using Date function

comp.databases.ms-access comp.databases.ms-access


Discuss DCount WHERE Clause using Date function in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
whiz
 
Posts: n/a

Default DCount WHERE Clause using Date function - 04-22-2010 , 07:41 AM






Hi, I'm using the DCount function where the WHERE clause portion is a
string variable. The string variable includes the Date function. I get
a "You Canceled The Previous Operation" at the point of the DCount and
suspect the problem is in the string variable.Below is my sting
variable assignment and DCount code. I appreciate any advice to fix.
Thanks.

strWhereIn = "([LISNRLS] < #" & Date & "#) AND ([LISNRLS] >= #" &
(Date - 7) & "#) AND ([PO#PR] Like ""G*"")"

rec("In") = DCount("[PO#PR]", strProgramTablePO, _
strWhereIn)

Reply With Quote
  #2  
Old   
Rich P
 
Posts: n/a

Default Re: DCount WHERE Clause using Date function - 04-22-2010 , 10:23 AM






DCount returns an integer value which would be the count of rows in a
table (or dataset -- query) that meet a giver criteria. I'm not sure
what -- rec("In") -- represents. Here is a sample usage of DCount
(including the source data -- from Table2)

'--source data for DCount example from Table2
fyear fld1 fld2

2000 abc1 abc12
2000 abc1 abc13
2001 abc1 abc12
2002 abc1 abc12
2002 abc1 abc13

Sub DcountThing()

Dim i As Integer
i = DCount("[fld2]", "Table2", "InStr(1,[fld2],'2')>0")
Debug.Print "i is " & i

End Sub

This will return a "3" because there are 3 rows where fld2 contains a
"2" in the value.

Rich

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.