Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
When you're writing an Or query with multiple values, sometimes using 'In' is better than using 'Or.' You can use the In operator when you need to determine whether a value equals one of many values. Let's look at our In-state query in Design View. I'll hold my cursor between the State and Work Phone columns, so I get a double headed arrow, and I'll double-click to spread it out. So here I'm looking for customers from within a set of states and this expression uses a series of Or operators.
California Or Nevada Or New Mexico Or Arizona Or Maryland Or Pennsylvania. A simpler alternative is to use the In operator. In parenthesis, California, Nevada New Mexico, Arizona Maryland Pennsylvania, and then I'll finish it off with my closing parenthesis but when I hit Tab, notice that I didn't even have to type in the quotation marks myself. Access put them in for me. See how much shorter an In statement is than an Or statement, and when I delete the Or statement and run the query again, it gives me the exact same result.
This syntax can also be used with validation rules, SQL statements and Macros anywhere you write code. When you want to check to see if a field is within a specific dataset, an In statement is a nice alternative to lengthy Or statements.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 64698 Viewers
80 Video lessons · 124318 Viewers
52 Video lessons · 60253 Viewers
59 Video lessons · 46084 Viewers