News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • filtering a query with IIf statement problem

    Posted on Weyrman Comment on the AskWoody Lounge

    Home Forums AskWoody support Productivity software by function MS Access and database help filtering a query with IIf statement problem

    Viewing 5 reply threads
    • Author
      Posts
      • #2276189 Reply
        Weyrman
        AskWoody Lounger

        I get code blocked when inserting the sql I want to ask about, so.

        I want to filter PO records only if a value is greater than 7. 7 is a rep number. I want reps greater than 7 to only see their own PO’s but anyone less (managers) to be able to see all PO’s.

        I’m trying to use an IIF statement with Like “*” as the false value but it returns nothing.

      • #2276192 Reply
        Weyrman
        AskWoody Lounger

        Here is a pic showing my code

         

        Annotation-2020-06-29-152634

        Attachments:
      • #2276199 Reply
        Paul T
        AskWoody MVP

        I would have expected something like “select * where userinfo > 7” rather than an IFF.

        cheers, Paul

      • #2276242 Reply
        jimatVirginiaSoftware
        AskWoody Plus

        Here’s what you want …  IIF(GetUserInfo()<=7,Rep,GetUserInfo())

        Jim

        1 user thanked author for this post.
      • #2276249 Reply
        doriel
        AskWoody Lounger

        Our Access teacher told us, that IIF is just normal IF, but it has to named otherwise not to colide with other IF function.

        iif

        Also, beware of the “wildcard symbol”. Since you work in access, * should be right, but maybe there should be just single quotation (alt+39) instead of double.
        https://www.w3schools.com/sql/sql_like.asp

        @jimatVirginiaSoftware solution seems viable.

        Dell Latitude E6530, Intel Core i5 @ 2.6 GHz, 4GB RAM, WX 1809 Enterprise

        HAL3000, AMD Athlon 200GE @ 3,4 GHz, 8GB RAM, Fedora 29

        Attachments:
      • #2276379 Reply
        Weyrman
        AskWoody Lounger

        Jim was right: IIf(GetUserInfo()<=7,([Rep]),GetUserInfo()) did the trick.

    Viewing 5 reply threads

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    Reply To: filtering a query with IIf statement problem

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.