Nz(DCount

L

Little Penny

What is the proper syntax of this dcount statement

=Nz(DCount("OperatingSystem","Workstations")","("OperatingSystem = "Windows 2000","),0)

I want it to count all the Operating System in the Workstation table that are equal Windows 2000

If I can do this a and want to add a third criteria for instance PhysicalMemory less than 1024k
How would I do that?




Thanks
 
G

George Nicholson

DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows
2000'")

DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows
2000' AND [PhysicalMemory] <1024")

AFAIK, the NZ function provides no useful purpose when using DCount,
although it does when using DLookup.

HTH,
 
L

Little Penny

I can't get this to work

I put this in the control source of a test box

DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows 2000'")


I get this #Name? in the box
 
G

George Nicholson

Preceded by an equal sign? OperatingSystem is the correct spelling of a
field in a table named Workstations?

--
George Nicholson

Remove 'Junk' from return address.


Little Penny said:
I can't get this to work

I put this in the control source of a test box

DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows
2000'")


I get this #Name? in the box









DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows
2000'")

DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows
2000' AND [PhysicalMemory] <1024")

AFAIK, the NZ function provides no useful purpose when using DCount,
although it does when using DLookup.

HTH,
 
E

Eric D via AccessMonster.com

Put the "=" back in the front of the statement.

Little said:
I can't get this to work

I put this in the control source of a test box

DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows 2000'")

I get this #Name? in the box
DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows
2000'")
[quoted text clipped - 6 lines]
 
L

Little Penny

=DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows 2000'")

Eric I get an error when I do this


Put the "=" back in the front of the statement.

Little said:
I can't get this to work

I put this in the control source of a test box

DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows 2000'")

I get this #Name? in the box
DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows
2000'")
[quoted text clipped - 6 lines]
 
E

Eric D via AccessMonster.com

Can you provide additional information?
Are you trying to use the DCount function in a macro, in code or form, or are
you trying to use the DCount function within a query?

If you are trying to use DCount in a query, you should switch to the Count
function using Totals.
If macro or form, then DCount is OK.

You must get the syntax of the statement correct in order for it to work
properly. This is not always easy, at first.
=DCount("[fieldyouwanttocount]", "Tablethatcontainsfieldyouwanttocount", "
[FieldToFilter] = ' FilterOnThis ' " )

To see if you have the first part correct, try:
=DCount("[OperatingSystem]", "Workstations")

This should give you the total number of records in you table - Workstations.
If you get the desired results here, you're better than half way home. If not,
you need to provide further information in order for someone to provide
addtional help. If this shortened statement works, add the Where clause. I
added spaces to this section so that you could see the single/double quotes
properly, you would not include these spaces.

I tested all of the above using a form and a textbox. If this is NOT what you
are doing, please clarify.



Little said:
=DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows 2000'")

Eric I get an error when I do this
Put the "=" back in the front of the statement.
[quoted text clipped - 11 lines]
 
E

Eric D via AccessMonster.com

Another item:

Is [OperatingSystem] the best field for you to count? Could it ever be null?
If so, you won't get the corrrect count.
You can simplify the statement by the following:

=DCount( " * ", "YourTable", "[FieldToFilter] = ' FilterGoesHere ' " )
(again, I added spaces in " * " - for clarity. You shouldn't)

Hope that helps!

Little said:
=DCount("[OperatingSystem]","Workstations","[OperatingSystem] = 'Windows 2000'")

Eric I get an error when I do this
Put the "=" back in the front of the statement.
[quoted text clipped - 11 lines]
 

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

Similar Threads

Dcount Again 2
Access Dcount (multiple criteria) 3
Still struggling with DCount 8
DCount problem redux 4
DCount criteria 7
DCount alwaysreturning 1 0
Repeat macro until record count of query = 0 0
DCOUNT unique records 2

Top