Count a specific value.

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

Guest

Hi all,

I’m trying to make a text box return a “count†from another field that
contains a specific value. I want the text box to give me a count of all the
records that contain “2320†but it gives me the count for all the values
instead.

My Expression builder code is =Count([DepPlusSize]="2320")

Can anyone tell me what is wrong with my code?

Thanks,

Cage
 
Try:
= - Sum([DepPlusSize] = "2320")

Omit the quotes if DepPlusSize is a Number field (not a Text field.)

The expression inside the brackets is True or False (or Null) for each
record. Access uses -1 for True, and 0 for False. Therefore summing the
expression gives the negative count of the cases where the expression is
True.
 
That worked! Thank you Stefan and Allen for your help on this one.


Allen Browne said:
Try:
= - Sum([DepPlusSize] = "2320")

Omit the quotes if DepPlusSize is a Number field (not a Text field.)

The expression inside the brackets is True or False (or Null) for each
record. Access uses -1 for True, and 0 for False. Therefore summing the
expression gives the negative count of the cases where the expression is
True.

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

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

cage4000 said:
Hi all,

I’m trying to make a text box return a “count†from another field that
contains a specific value. I want the text box to give me a count of all
the
records that contain “2320†but it gives me the count for all the values
instead.

My Expression builder code is =Count([DepPlusSize]="2320")

Can anyone tell me what is wrong with my code?

Thanks,

Cage
 
This worked perfectly on my report. Now, I would like also have my report
count from those "2320"s to also count if another field is "d". Further down
on my report I would also like to go one more so it will count if "2320" and
"d" and "yes" are all true. I hope this makes sense. I would like to take
this count one step further and count based on 2 fields (and then three). I
wasn't sure how to add the next phase. Any help is greatly appreciated.

Allen Browne said:
Try:
= - Sum([DepPlusSize] = "2320")

Omit the quotes if DepPlusSize is a Number field (not a Text field.)

The expression inside the brackets is True or False (or Null) for each
record. Access uses -1 for True, and 0 for False. Therefore summing the
expression gives the negative count of the cases where the expression is
True.

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

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

cage4000 said:
Hi all,

I’m trying to make a text box return a “count†from another field that
contains a specific value. I want the text box to give me a count of all
the
records that contain “2320†but it gives me the count for all the values
instead.

My Expression builder code is =Count([DepPlusSize]="2320")

Can anyone tell me what is wrong with my code?

Thanks,

Cage
 
AccessNewbie said:
This worked perfectly on my report. Now, I would like also have my report
count from those "2320"s to also count if another field is "d". Further down
on my report I would also like to go one more so it will count if "2320" and
"d" and "yes" are all true. I hope this makes sense. I would like to take
this count one step further and count based on 2 fields (and then three). I
wasn't sure how to add the next phase. Any help is greatly appreciated.

Allen Browne said:
Try:
= - Sum([DepPlusSize] = "2320")

Omit the quotes if DepPlusSize is a Number field (not a Text field.)

= - Sum([DepPlusSize] = "2320" And field2 = "d")
= - Sum([DepPlusSize] = "2320" And field2 = "d" And field3 =
"yes")
 
thanks for the quick response. I have the query working but now I would also
like to know how to change the last AND to where it will only count if the
field is not null. Could you help with that?

Marshall Barton said:
AccessNewbie said:
This worked perfectly on my report. Now, I would like also have my report
count from those "2320"s to also count if another field is "d". Further down
on my report I would also like to go one more so it will count if "2320" and
"d" and "yes" are all true. I hope this makes sense. I would like to take
this count one step further and count based on 2 fields (and then three). I
wasn't sure how to add the next phase. Any help is greatly appreciated.

Allen Browne said:
Try:
= - Sum([DepPlusSize] = "2320")

Omit the quotes if DepPlusSize is a Number field (not a Text field.)

= - Sum([DepPlusSize] = "2320" And field2 = "d")
= - Sum([DepPlusSize] = "2320" And field2 = "d" And field3 =
"yes")
 
AccessNewbie said:
I have the query working but now I would also
like to know how to change the last AND to where it will only count if the
field is not null.

Marshall Barton said:
= - Sum([DepPlusSize] = "2320" And field2 = "d")
= - Sum([DepPlusSize] = "2320" And field2 = "d" And field3 =
"yes")


= - Sum([DepPlusSize] = "2320" And field2 = "d" And field3
Is Not Null)
 
Back
Top