Results 1 to 9 of 9
  1. #1
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128

    Iif not working as a part of criteria

    I'm using this expression in the criteria of a query



    Code:
    IIf([FBA? Y/N]="Y",>0,=0 Or Is Null)
    I'm using a parameter [FBA? Y/N] which I've defined as text. I've used >0 and =0 Or Is Null as criteria without the Iif and it works fine. What the heck am I missing?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is this in query criteria? Cannot have dynamic operators (>, <, =, etc).

    Recommend no spaces or special characters/punctuation (underscore is exception) in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    Yes, it's a query criteria.

    If I need to use a dynamic operator based on the input of the parameter, how can I do this?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Don't use dynamic parameterized query - I NEVER do.

    Review: http://www.allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    Ok, so use a form to create this instead? Geez, I don't want to make it that complicated. I'm the only one who will use the thing but don't want to fill in the criteria in the query each time I run it

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Not aware of any other options.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    I get it. Access forces rigorous integrity. Part of using it. But a pain in the a$$ in this case

  8. #8
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    I guess I could just generate the table, then sort by values, but I like to have the sorting done so the query just comes through clean.

  9. #9
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you can use vba to build your query sql to pass to a querydef or if your table is the recordsource to your form, build a filter

    e.g.

    form recordsource=tblData

    have a button to create your filter based on whatever parameters you are using

    I'll assume you want FBA to be text (Y or N) and is an unbound control called FBA, the code to build the button would be

    Code:
    me.filter="[SomeField] " & IIf([FBA]="Y",">0","=0 Or [SomeField] Is Null")
    me.filteron=true

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

Similar Threads

  1. Criteria not working
    By MFS in forum Queries
    Replies: 7
    Last Post: 03-27-2014, 07:36 AM
  2. Criteria in query is not working
    By sshel55 in forum Queries
    Replies: 7
    Last Post: 10-17-2013, 04:50 PM
  3. How Can export Large table part by part
    By shabar in forum Import/Export Data
    Replies: 2
    Last Post: 02-04-2013, 06:29 AM
  4. Last Part of code not working
    By mejia.j88 in forum Programming
    Replies: 19
    Last Post: 02-22-2012, 12:36 PM
  5. Replies: 1
    Last Post: 10-25-2011, 09:47 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