Re: Calculate certain number of records



Since the value to be matcheds is text, I take it that MyField is a Text
field (not a Number field.)

Your 2nd exampls should work.

The * tells Access to count all fields where there is a match.

If it still fails, press Ctrl+G to open the Immediate window.
There type the expression an press enter:
? DCount("*", "MyTable")
That should give you the total number of records in the table.

Now try:
? DCount("*", "MyTable", "MyField = 'abc'")

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"john" <john@xxxxxxxx> wrote in message
news:78WdnTDbqOnCnSfZnZ2dnUVZ8qKdnZ2d@xxxxxxxxxxxx
Thanks, but I can't get it to work even after reading the explanation.
=DCount("*", "MyTable", "MyField = abc")
or
=DCount("*", "MyTable", "MyField = 'abc'")
are not accepted as an expression.
What does the * stand for in the expression, btw?

To make sure we're talking about the same thing. I want a field on my form
that has no relation with the current record. It should show the number of
records of the whole table where the value of MyField is abc.
john

"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> schreef in bericht
news:44b8b833$0$21733$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
This kind of thing should work:
=DCount("*", "Table1", "ClientID = 99")

The arguments DCount() needs are the same as for DLookup(), so if you are
having difficulty supplying the 3rd one, see the explanation in this
article:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html

"john" <john@xxxxxxxx> wrote in message
news:aqSdneDWqZ99AiXZnZ2dnUVZ8s2dnZ2d@xxxxxxxxxxxx
I have a form with 1 table. I would like to create a field in my form
that shows the number of records (of the whole table) that have one
particular value. Is that possible? I fiddled with a calculated field but
I couldn't make it work.
Thanks in advance,
john


.



Relevant Pages

  • Re: Calculate certain number of records
    ... press Ctrl+G to open the Immediate window. ... Tips for Access users - http://allenbrowne.com/tips.html ... Getting a value from a table: DLookup() ...
    (comp.databases.ms-access)
  • Re: Need some help with MOVENEXT/MOVEPREVIOUS
    ... John wrote: ... Your database has only one record with '123' in MYFIELD ... That's why opening the database then opening a recordset query works. ... Doing the select and the routine, the table is filled with the requested record. ...
    (microsoft.public.vb.database.dao)
  • Re: Need some help with MOVENEXT/MOVEPREVIOUS
    ... MYFIELD in the db is a numeric key field. ... John ... "argusy" wrote: ... > That's why opening the database then opening a recordset query works. ...
    (microsoft.public.vb.database.dao)
  • Re: Reduce size of data
    ... SELECT MyField FROM MyTable ORDER BY MyField DESC; ... If MyField is an unindexed Decimal field, ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Reduce size of data
    ... I find it extremely embarrassing that JET 4 gets this query wrong: ... SELECT MyField FROM MyTable ORDER BY MyField DESC; ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ...
    (microsoft.public.access.tablesdbdesign)

Loading