Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-17-2018, 08:19 AM   #1
RevJeff
Newly Registered User
 
Join Date: Sep 2002
Posts: 95
Thanks: 8
Thanked 4 Times in 2 Posts
RevJeff
Question Query Criteria with a wilcard

Hello,

I am trying to setup a query that looks at a ComboBox named "Location". If "All" is selected in the ComboBox, I want everything displayed in the query, but if a certain location is selected, then the query only displays that locations information. That part works fine. It's that "All" part that I am having issues with. Below is the code I have in the Criteria field in the query.

Code:
IIf([Forms]![frmDashboard]![Location]="All",Like "*",[Forms]![frmDashboard]![Location])
Thanks for your help.

RevJeff is offline   Reply With Quote
Old 05-17-2018, 08:23 AM   #2
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,526
Thanks: 132
Thanked 1,492 Times in 1,464 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: Query Criteria with a wilcard

You don't need the "All" , have it default to Null value, then in the criteria put the following

Code:
=[Forms]![frmDashboard]![Location] Or [Forms]![frmDashboard]![Location] Is Null
This will bring back all values if the combo is null, and can be repeated for multiple combo's.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is online now   Reply With Quote
The Following User Says Thank You to Minty For This Useful Post:
RevJeff (05-17-2018)
Old 05-17-2018, 08:30 AM   #3
RevJeff
Newly Registered User
 
Join Date: Sep 2002
Posts: 95
Thanks: 8
Thanked 4 Times in 2 Posts
RevJeff
Re: Query Criteria with a wilcard

That works perfectly! Thank you!

RevJeff is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Query based on multiple criteria, show only results that match both criteria Scaniafan Queries 11 08-25-2017 05:08 AM
Wilcard (aka LIKE) Query in Search Forms oblivion86 Queries 4 08-28-2012 05:59 AM
Access 2000: Wilcard in Access SQL statement? BrianE Queries 7 03-06-2008 06:13 AM
Setting query criteria to be 'blank' depending on the criteria of a combo box whitty15 Queries 5 10-22-2006 10:35 PM
Wilcard Searches Ice Rhino SQL Server 2 05-13-2006 08:32 PM




All times are GMT -8. The time now is 06:45 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World