Results 1 to 2 of 2
  1. #1
    dougperk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    2

    IN operator

    In the Autoexec macro I can insert either of the following expression into the IF command and it evaluates successfully.
    UsernameWindows() = "Person1"
    UsernameWindows() IN ("Person1", "Person2")

    But if I try to use any of the following IN expressions, I receive an error upon save, stating the "Access cannot parse the expression".
    UsernameWindows() IN (Select tblUserPermissions.UserName from tblUserPermissions)
    UsernameWindows() IN (Select [tblUserPermissions].[UserName] from [tblUserPermissions])
    UsernameWindows() IN (tblUserPermissions.UserName from tblUserPermissions)

    How do I need to write that expression. Ideally I want it to also include a WHERE such as:
    UsernameWindows() IN (Select tblUserPermissions.UserName from tblUserPermissions Where tblUserPermissions.OpenDashboard = "Yes")



    Any suggestions?
    Doug

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    IN parses a string looking for a value if you want to look up a user from a table you would have to use dlookup or some other method to find the user for instance:

    if dcount("*", "tblUserPermissions", "[UserName] = '" & usernamewindows() & "'") > 0 then

    this would return a TRUE if the person's username existed in your table, FALSE if it didn't (count of records would be 0)

    if you want to lookup a person's password you'd use dlookup like

    sUserPW = dlookup("[UserPassword]", "tblUserPermissions", "[UserName] = '" & usernamewindows() & "'")

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

Similar Threads

  1. AND Operator in the Query
    By drunkenneo in forum Queries
    Replies: 1
    Last Post: 06-09-2014, 11:27 PM
  2. Between And operator gives inconsistent result
    By Reaper in forum Programming
    Replies: 6
    Last Post: 02-09-2013, 09:46 AM
  3. Operand without operator or
    By burrina in forum Queries
    Replies: 2
    Last Post: 12-31-2012, 06:14 PM
  4. Or operator
    By Rhubie in forum Access
    Replies: 1
    Last Post: 09-06-2012, 04:42 PM
  5. in operator
    By pchang in forum Access
    Replies: 1
    Last Post: 01-16-2011, 06:24 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