DCount Method

  • Thread starter Thread starter Gina Liddle
  • Start date Start date
G

Gina Liddle

I'm trying to count the number of records displayed in a form once a filter
has been applied within that form. The code used returns the total number of
records in the query regardless of criteria (filter). Anyone know why??

RecNo = DCount("[TextField]", "[QueryA]", Me.Filter)
 
Answer to question...because you told it to. Now on to how to stop that...

DCount returns the number of selected records unless you tell it to count
only the number of records YOU selected.

DCount(expression,domain[,criteria])

So in essence your query should read

RecNo = DCount("[TextField]", "QueryA",[ x]=Form.[y]")

x=Something in you query that uniquely identifies the the records you want
to count that also equals...
y=Something on the form identifying the same records like

Only count records for this employee would mean x=EmployeeID and
y=EmployeeID. Then DCount would only count the records for that Employee

Hope that helps...
 
Back
Top