Solved

Microsoft Query Parameters.....simple!

Posted on 2004-04-28
11
667 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…

856 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