Solved

Microsoft Query Parameters.....simple!

Posted on 2004-04-28
11
642 Views
Last Modified: 2008-02-01
I am using Microsoft Query within Excel to source some reports feeding from an access table.

I wanted to put filters on the data and have setup a feed that picks the filter criteria from another sheet within the excel workbook which works fine.

My problem is:
What if I want to show all records in the query and apply no filter? Based on the current configuration if I leave the cells that determine the filters blank then the query returns nothing. I thought by using "*" that might pull everything but it doesn't seem to.

I'm sure it must be simple!!!

Any ideas?

0
Comment
Question by:JGWY
11 Comments
 

Expert Comment

by:joebrez
ID: 10938830
Do you have field in the query that might make it a null query?
0
 

Author Comment

by:JGWY
ID: 10938855
No, unless the last row of the access table which is always blank for the next line of data is causing this?
0
 
LVL 17

Expert Comment

by:walterecook
ID: 10939047
How about posting the SQL.  Maybe you have an errant space in there or something.

Walt
0
 

Author Comment

by:JGWY
ID: 10939125
HEre ya go....

SELECT `emea1-3`.ORIG_COST_CTR, `emea1-3`.CHRG_COST_CTR, `emea1-3`.LVL1_GEO_NM, `emea1-3`.LVL2_GEO_NM, `emea1-3`.LVL3_GEO_NM, `emea1-3`.LVL2_LOB_NM, `emea1-3`.LVL3_LOB_NM, `emea1-3`.LVL4_LOB_NM, `emea1-3`.`TIER$_PROD_DS`, `emea1-3`.TIER0_PROD_DS, `emea1-3`.TIER1_PROD_DS, `emea1-3`.YEAR_NO, `emea1-3`.MO_NO, `emea1-3`.SumOfBILL_CHRG_VOL_CT, `emea1-3`.SumOfBILL_CHRG_AM, `emea1-3`.BILL_CHRG_TYPE_CD, `emea1-3`.ORIG_COST_CTR
FROM `C:\Documents and Settings\jgwynn\Desktop\TechSingleInvoice`.`emea1-3` `emea1-3`
WHERE (`emea1-3`.ORIG_COST_CTR=?)

If I source the parameter for "orig_cost_ctr" as say sheet2!b4, and leave the cell blank, nothing is returned, in this case I want everything to be returned.)
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 17

Expert Comment

by:walterecook
ID: 10939646
Therein lies the problem.  It sees it as empty and is thus looking for data that = ""
You'll probably need to evaluate that cell first with an if. If it's empty use the query with no where clause.  If it isn't, use the current query.

Walt
0
 

Author Comment

by:JGWY
ID: 10939791
is there not a wildcard that can be inserted into the cell that represents all fields?

I'm thinking of using around 5 parameters and this could be really messy if i have to evaluate all first?
0
 
LVL 17

Accepted Solution

by:
walterecook earned 50 total points
ID: 10940756
There is and it is *
But you are saying make the condition = to the contents of the cell.  The cell is empty which is ""
So the query says "ok find me records that = ""

Walt
0
 
LVL 5

Expert Comment

by:usarian
ID: 11094387
If I could make a suggestion,  How about triggering a small vba routine to perform the query if the cell contains, say the word "all"?
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Often, when running a query with joins, the results show up "duplicates", and often, those duplicates can be "eliminated" in the results using DISTINCT, for example. Using DISTINCT is simple: just add it after the SELECT keyword, an…
Creating and Managing Databases with phpMyAdmin in cPanel.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now