Solved

Microsoft Query Parameters.....simple!

Posted on 2004-04-28
11
671 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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…

685 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