Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    89

    Unanswered: How can I check for a group in an Access report?

    Hi. I've got a report with three groups in. the first gorup shows everytime, but the 2nd and third might not show. How Can i check if the 2nd and 3rd groups are empty?

    I need something like
    Code:
    =IIF( NZ(Group1,"")= "" & NZ(Group2,"")= "","No Groups", null)

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    What do you want to show if the groups exist. I think you are on the right path but you might be getting confused with the Ands. This is what I think you are looking for:

    Code:
    IIf(([Group2] & ""="") And ([Group3] & ""=""), "No Groups","")
    My code displays No Groups if Group2 and Group3 are both Null or "". Otherwise it will show "" or an empty string (blank).

  3. #3
    Join Date
    Jun 2009
    Posts
    89
    Ended up using:
    Code:
     Iif(Count(*) = "1", "No Groups", Null)
    works well !

    Dont' really udnerstand what the difference is between your
    Group1 & " "=" "
    and my
    NZ(Group1,""), which will return "" if group1 is null. In your case though, if Group1 is null will it not cause errors as you're not checking for null?

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    If you concatenate Null and the empty string (Null & "") you get the empty string. If you concatenate the empty string with the empty string ("" & "") you get the empty string. The result of the code is the same. The difference is my code does not call a function to get the result (Nz). I haven't tested it, but I believe my code is faster. By how much, I don't know. I suppose it is personal preference without any facts to back it up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •