View Full Version : Count on Query and Displaying result on a switchboard


ciskid
07-31-2006, 01:16 PM
Hi Folks

More questions from the newbie :eek:

I have a very simple table with a field that will have only the values open or closed

I created a query based on this table and used the count function (to count open or closed cases) and in the next querie field I used the group by open.

This gives me a count of all open cases

I can do the same for closed cases.

I want this count to be displayed on a Switchboard form but i cant get my nehad round how to get it there.

Can anyone help me out ?

Many thanks

Jimmy

neileg
08-01-2006, 01:12 AM
Use DCount() rather than an aggregate query as the data source for a text box on your form.

ciskid
08-01-2006, 05:01 AM
Use DCount() rather than an aggregate query as the data source for a text box on your form.


Hi Neileg

Can you be more specific ?

For instance I have a table that has filed of different colours

Red , green , blue

If I create a form from this table , Do I build an expression to show the dcount total of these words , or a macro , or code ?

That's what I'm struggling with.

Can I use the expression builder ?

Thanks again

Jimmy
:confused:

neileg
08-01-2006, 05:28 AM
Have you looked at Access Help for DCount()?

You can use the expression builder.

ciskid
08-01-2006, 08:13 AM
Hi neileg


Still trying to use the expression bulder to do this.

Can I confirm some action points with you ?

So I have a form based on a table or query.

Say I have a field within this table or query called "count"

This is a field that has a value of 1 , so every time there is a new record, a "1" appears in this filed.

I then goto my form in design view , create a text box, right click and use the expression builder and write something like :-

=DCount("*","[table]","[count] = '1'")


Is the above correct.

br

Jimmy

neileg
08-02-2006, 01:27 AM
First thing, Count is a reserved word so you shouldn't use it as a field name say OpenClose. If [Count] has a value of 1 in every record I can't see the point so I presume you mean it is set to 1 for closed and zero for open (or vice versa).

With DCount you only use "*" without a criterion, DCount("*","table"). What you need is to specify a field (any one that isn't null, perhaps the primary key). DCount("PK","table","[OpenClose]='1'")

ciskid
08-03-2006, 08:07 AM
Hi neileg

Ok now all sorted.

Chuffed, many thanks for this.

Its really sorted me out.

br

Jimmy