Results 1 to 14 of 14
  1. #1
    ErnieS is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    15

    Count in Forms


    I'm new to Access but have been able to accomplish a lot.
    I need help with a "count" of records that contains certain information.
    I have form Labeled "PPC data". The form included fields from a table labeled "PP Files".

    I want to have a count of a field labeled "Lit Status" that has a value of "Remove From Inventory" as long as another field labeled "Lit Complete" has a value of "No".

    I've tried to figure this out in expression builder but have had no luck.
    Can anyone help me with this?

    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Try

    =Sum(IIf([Lit Status] = "Remove From Inventory" AND [Lit Complete] = "No", 1, 0))

    The spaces in your field names will prove to be more trouble than they're worth in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ErnieS is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    15
    No it didn't work. It didn't work like you posted so I tried this and it still didn't work:
    =Sum(If([Litigation PP Files]![Lit Status]="Remove From Inventory" And [Litigation PP Files]![Lit Complete]="No",1,0))

    The text box is "unbound". Does that matter. I didn't get any errors just nothing.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I should have mentioned that should be in the form footer. Is it? If Lit Complete is a Yes/No field in the table, that test would be:

    [Lit Complete]=False

    or

    [Lit Complete]=0
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ErnieS is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    15
    Lit Complete is a yes/No field so I changed it as follows:
    =Sum(If([Litigation PP Files]![Lit Status]="Remove From Inventory" And [Litigation PP Files]![Lit Complete]=0))

    I also tried Lit Complete = False.
    These did not work.

    The text box that has this expression is not in the footer. It is in the Body of the Form which is where I wanted the count. Does this matter?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I think it will still work in the body, but you need to go back to the syntax I posted (adjusted for the Yes/No field). "If" won't work there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    ErnieS is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    15
    Does that mean that I need to remove the "If" ?
    Can you post the entire Expression?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    =Sum(IIf([Lit Status] = "Remove From Inventory" AND [Lit Complete] = 0, 1, 0))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    ErnieS is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    15
    I really appreciate all of your help but it's not working.
    I typed it like this:
    =Sum(IIf([Litigation PP Files]![Lit Status]="Remove From Inventory" And [Litigation PP Files]![Lit Complete]=0,1,0))
    Any other suggestions?

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Can you post the db, or a sample of it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    ErnieS is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    15
    So I changed this to:
    =Count(IIf([Litigation PP Files]![Lit Status]="Remove From Inventory" And [Litigation PP Files]![Lit Complete]=False,1,0))

    It won't work with "Sum". It works with "Count", however, it gives me all records and includes records that have other than "Remove From Inventory", and "Lit Complete NO.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I tested using Sum and a similar expression in a form and it worked as expected. I take it you can't post the db, or a sample to test with?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    ErnieS is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    15
    Unfortunately I can't post it as it has confidential information.
    If I change to "sum" the I get 0
    Using "Count" it counts all of my records and does not exclude the fields that I want excluded.

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Make sure the first field doesn't have a table level lookup defined. It could be storing an ID number but displaying the text. If that's the case, you would need to change your test to the appropriate number.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Count of records
    By Aston in forum Access
    Replies: 2
    Last Post: 03-30-2010, 05:20 AM
  2. error in count
    By humpz in forum Reports
    Replies: 6
    Last Post: 08-13-2009, 08:20 AM
  3. Using count or Dcount
    By ddcook in forum Access
    Replies: 0
    Last Post: 07-22-2009, 03:35 PM
  4. how do i do a word count
    By clueless in forum Queries
    Replies: 0
    Last Post: 06-03-2009, 09:01 PM
  5. Replies: 4
    Last Post: 04-01-2009, 08:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums