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

Variables in DCount

Status
Not open for further replies.

ohmbru

Technical User
Jul 13, 2001
161
US
Can anyone help me figure out what I'm doing wrong here:

RecCount = DCount(strTotTableName & "!effdate", strTotTableName, strTotTableName & "!effdate = " & M & Y)

strTotTableName, M, and Y are my variables. I'm sure this has to do with the quote marks, but I have tried several things and can't seem to get the syntax right.


Brian
 
Assuming that M & Y are text variable then try changing it to this:

RecCount = DCount(strTotTableName & "!effdate", strTotTableName, strTotTableName & "!effdate = '" & M & Y & "'")

Ascii dumb question, get a dumb Ansi
 
That didn't work either. DCount is so finicky. Is there possibly another way to count the records?

Brian
 
DCount(strTotTableName & "!effdate"

The Strtottablename contains the able name, and effdate is the field you want counted yes? Try also dropping everyting and just use "[effdate]"

Sometimes if I have problems like this, and after about a month I cant figure it out, I will cheat and write a query that includes only the records I want counted, then base my dcount on that query instead of on the Table.

Maybe this will also work for you?

ChaZ

Ascii dumb question, get a dumb Ansi
 
I will give that a try, but the records I'm counting need to meet a couple of conditions.

Thanks,



Brian
 
ohmbru,

Here some code I recently used for a DSum. I would think the count function is similar:
=DSum("[Amount]","[TotalTrans]","[Reviewed] and [NC] =[qryByNC-Jeff].[NC]")

This code is place in a text box at end of my Access report - in the footer section. I am getting a sum of Amount field in tabel TotalTrans. My condition for defining what records to sum is field [Reviewed] be true AND field [NC] be equal to the value of field [NC] is a query.

Hope this gives some insight. By the way [NC] stands for Natural Class, which is an accounting code that distinguishes types of costs.
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top