how to count the number of records pulled by a query.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i am having a query pull records from a table based on a certain criteria. as
well as the record data, I also need a count of the number of records that
match that criteria, and I need that number assigned automatically to the
default value of a text box. I think i'm probably missing a simple solution
to this
problem, but I just cant get the stinkin' thing to count the records. If I
try the count or Dcount functions the form just displays #Name$ or something
like that. Please help...
 
DCount is how I'd first approach it. The #Name? error that you see likely is
because of a syntax error, or more likely a name confusion error (your
expression may be using a field name that also is a control on the form, but
the control isn't bound to that field of the same name). Post what your
setup is and what you've tried.
 
I used a query to pull all records that showed the member in question as
being present, or more specifically not absent. Then I tried to use the
DCount function as follows. default value =DCount([Last Name],[Availible
Members]) where [Last Name] is just a field to count the rows availible, and
[Availible Members] is the name of the query used to pull those records. I
actually have gotten around this problem by having a listbox control display
the query contents, and counting the rows in the list box using default
value=[mbravailible].[ListCount]. A screenshot of is availible if more
information would be helpfull.
 
Using this expression as the DefaultValue property of the textbox should
give you your desired results:

=DCount("*","Availible Members")


--

Ken Snell
<MS ACCESS MVP>

gpperrone said:
I used a query to pull all records that showed the member in question as
being present, or more specifically not absent. Then I tried to use the
DCount function as follows. default value =DCount([Last Name],[Availible
Members]) where [Last Name] is just a field to count the rows availible, and
[Availible Members] is the name of the query used to pull those records. I
actually have gotten around this problem by having a listbox control display
the query contents, and counting the rows in the list box using default
value=[mbravailible].[ListCount]. A screenshot of is availible if more
information would be helpfull.

Ken Snell said:
DCount is how I'd first approach it. The #Name? error that you see likely is
because of a syntax error, or more likely a name confusion error (your
expression may be using a field name that also is a control on the form, but
the control isn't bound to that field of the same name). Post what your
setup is and what you've tried.

--

Ken Snell
<MS ACCESS MVP>

criteria.
as If
I
 
Back
Top