DCount Method

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)
 
G

Gina Whipp

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top