Help on counting in a form

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

Guest

I have a table Purchasers that has fields named, Project, Resvdate,
Conv,Closed. I would like to be able to count the number of Resvdate when the
project = "Oak Ridge" and the Closed date is Null. On the same form another
line have the same expression but with the Project = "Glen Garden"
Not sure if I should try an IIF statement or a Dcount.

Thanks for any help
 
If you want the count to show on each row, matching the project in the
Project field of that record:
=DCount("*", "Purchasers", "(Project = """ & [Project] &
""") AND ([Closed date] Is Null)")

That assumes the Project field is Text.
Lose the extra quotes if it is a Number type field.
 
Allen, thanks for the quick reply. I am new at this so please bear with me.
I tried what you suggested and just got error messages.
One control box on the form would read Number of resvdate where Project =
Glen Garden and Closed is empty
the next box on the fomr would read Number of resvdate where Project = Oak
Ridge and Closed in blank(or null)
The project name is text and resvdate and closed are dates

This is a managment report so these would be the only two boxes on the form


Allen Browne said:
If you want the count to show on each row, matching the project in the
Project field of that record:
=DCount("*", "Purchasers", "(Project = """ & [Project] &
""") AND ([Closed date] Is Null)")

That assumes the Project field is Text.
Lose the extra quotes if it is a Number type field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Tom Carlsen said:
I have a table Purchasers that has fields named, Project, Resvdate,
Conv,Closed. I would like to be able to count the number of Resvdate when
the
project = "Oak Ridge" and the Closed date is Null. On the same form
another
line have the same expression but with the Project = "Glen Garden"
Not sure if I should try an IIF statement or a Dcount.

Thanks for any help
 
If you are not trying to stick the value of the Project from the current row
into the epression, perhaps you want a Control Source like this:
=DCount("*", "Purchasers", "(Project = ""Oak Ridge"") AND ([Closed date]
Is Null)")

To help you get the expression right, open the Immediate window (Ctrl+G).
You can play with the expression there until you get it right. Just use ?
instead of =, and break it down into smaller chunks until it works, e.g.:
=DCount("*", "Purchasers", "(Project = ""Oak Ridge"")")

Again, if Project is a Number type field in your table (not a Text field),
this example will not match correctly.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Tom Carlsen said:
Allen, thanks for the quick reply. I am new at this so please bear with
me.
I tried what you suggested and just got error messages.
One control box on the form would read Number of resvdate where Project =
Glen Garden and Closed is empty
the next box on the fomr would read Number of resvdate where Project = Oak
Ridge and Closed in blank(or null)
The project name is text and resvdate and closed are dates

This is a managment report so these would be the only two boxes on the
form


Allen Browne said:
If you want the count to show on each row, matching the project in the
Project field of that record:
=DCount("*", "Purchasers", "(Project = """ & [Project] &
""") AND ([Closed date] Is Null)")

That assumes the Project field is Text.
Lose the extra quotes if it is a Number type field.

Tom Carlsen said:
I have a table Purchasers that has fields named, Project, Resvdate,
Conv,Closed. I would like to be able to count the number of Resvdate
when
the
project = "Oak Ridge" and the Closed date is Null. On the same form
another
line have the same expression but with the Project = "Glen Garden"
Not sure if I should try an IIF statement or a Dcount.
 
Allen, It worked - thankyou so much for the help..

Allen Browne said:
If you are not trying to stick the value of the Project from the current row
into the epression, perhaps you want a Control Source like this:
=DCount("*", "Purchasers", "(Project = ""Oak Ridge"") AND ([Closed date]
Is Null)")

To help you get the expression right, open the Immediate window (Ctrl+G).
You can play with the expression there until you get it right. Just use ?
instead of =, and break it down into smaller chunks until it works, e.g.:
=DCount("*", "Purchasers", "(Project = ""Oak Ridge"")")

Again, if Project is a Number type field in your table (not a Text field),
this example will not match correctly.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Tom Carlsen said:
Allen, thanks for the quick reply. I am new at this so please bear with
me.
I tried what you suggested and just got error messages.
One control box on the form would read Number of resvdate where Project =
Glen Garden and Closed is empty
the next box on the fomr would read Number of resvdate where Project = Oak
Ridge and Closed in blank(or null)
The project name is text and resvdate and closed are dates

This is a managment report so these would be the only two boxes on the
form


Allen Browne said:
If you want the count to show on each row, matching the project in the
Project field of that record:
=DCount("*", "Purchasers", "(Project = """ & [Project] &
""") AND ([Closed date] Is Null)")

That assumes the Project field is Text.
Lose the extra quotes if it is a Number type field.

I have a table Purchasers that has fields named, Project, Resvdate,
Conv,Closed. I would like to be able to count the number of Resvdate
when
the
project = "Oak Ridge" and the Closed date is Null. On the same form
another
line have the same expression but with the Project = "Glen Garden"
Not sure if I should try an IIF statement or a Dcount.
 
Back
Top