Results 1 to 11 of 11
  1. #1
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65

    Do nothing criteria

    Hi guys!

    I use the following criteria in a query for a specific field:



    Code:
    Like IIf([TempVars]![CurentUser]="ADMIN","*",[TempVars]![CurentUser])
    The join properties of the tables in the query is set up on 2.
    If the current user is admin, it returns all values, except of the null values.

    How can I make it return everything (including the null values)?

    Many thx!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    button click event:

    if admin then
    docmd.openquery "qsAllRecs"
    else
    docmd.openquery "qs1User"
    endif

  3. #3
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Thx ranman256!

    The query opens a combo box list. What should I have in the row source?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    or you could try

    myfield like [TempVars]![CurentUser] or [TempVars]![CurentUser]="ADMIN"

  5. #5
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    I'm sorry Ajax, but I didn't get it. What do you mean?

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    You didn't provide the full criteria

    myfield like [TempVars]![CurentUser] or [TempVars]![CurentUser]="ADMIN"

    the bit in red replaces this

    Like IIf([TempVars]![CurentUser]="ADMIN","*",[TempVars]![CurentUser])

    so if current user is ADMIN, all records are returned. If currentuser <> ADMIN then only those records relating to the current user are returned

  7. #7
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Thx Ajax!

    This is the full criteria, that is filtering a field in the query which is the row source for a combo box.
    By simply replacing the Like IIf([TempVars]![CurentUser]="ADMIN","*",[TempVars]![CurentUser]) with Like [TempVars]![CurentUser] or [TempVars]![CurentUser]="ADMIN", the query returns nothing.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    This is the full criteria
    well actually it's not. A criteria is what appears after the word WHERE - all you are showing is some of it.

    So without seeing the full sql, it is impossible to comment

    Also, to be clear -

    1. what is the value of [TempVars]![CurentUser] when you run your query?
    2. what happens if you remove the WHERE clause - are all records returned?
    3. have you confirmed [TempVars]![CurentUser] is not null? - easy way to do this is to remove your where clause and include [TempVars]![CurentUser] as a field i.e. something like

    SELECT *, [TempVars]![CurentUser] as TC
    FROM myTable

    4. can you confirm your combobox is set up to show the required values - and does so if the where clause is removed

  9. #9
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Hi Ajax!

    Sorry for the delay.

    I don't know what happened when I first tried your criteria and didn't work. Now is working great.

    Thx a lot!

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    got there in the end!

  11. #11
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Yeah!

    Thx again Ajax!

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

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  2. Replies: 4
    Last Post: 08-30-2014, 10:23 AM
  3. Replies: 5
    Last Post: 09-20-2012, 03:27 PM
  4. Replies: 5
    Last Post: 08-02-2012, 09:44 AM
  5. Replies: 1
    Last Post: 07-13-2011, 11:00 AM

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