ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unable to parameters in MicrosoftQuery (https://www.excelbanter.com/excel-programming/414405-unable-parameters-microsoftquery.html)

Captain Query

Unable to parameters in MicrosoftQuery
 
I have a quite large sql query that I want to use for fetching data i´nto an
Excel sheet. The query returns four columns and I want to use parameters for
two of these.

My problem is that my sql query cant be displayed grafically in
MicrosoftQuery and therefore I am not allowed to use parameters.

My question is: What determines if a sql question can be displayed grafically?

Pleas enlighten me.

Mike

joel

Unable to parameters in MicrosoftQuery
 
I usually set up my querries by recording a macro while I manually perform
the query. then modify the recorded macro putting variables as required.

the trick in adding parameter is the query is one long string. You have to
break up the string into parts like this

querystring = "abcdefghijklmnop"

Variable1 = "def"
Variable2 = "ijkl"
querystring = "abc" & Variable1 & "fgh" & Variable2 & "mnop"


Look at the recorded query and see where the double ("") quotes are located
which indicates the beginning and end of the string.


"Captain Query" wrote:

I have a quite large sql query that I want to use for fetching data i´nto an
Excel sheet. The query returns four columns and I want to use parameters for
two of these.

My problem is that my sql query cant be displayed grafically in
MicrosoftQuery and therefore I am not allowed to use parameters.

My question is: What determines if a sql question can be displayed grafically?

Pleas enlighten me.

Mike


Jim Thomlinson

Unable to parameters in MicrosoftQuery
 
MS Query only allows for simple queries to be displayed. Anything more
elaborate than a simple Select/From/Where/GroupBy/Having/SortBy is not
supported. So if you have nested select statements or ... you are out of
luck. At that point you need to get into using VBA with an ADODB connection.
--
HTH...

Jim Thomlinson


"Captain Query" wrote:

I have a quite large sql query that I want to use for fetching data i´nto an
Excel sheet. The query returns four columns and I want to use parameters for
two of these.

My problem is that my sql query cant be displayed grafically in
MicrosoftQuery and therefore I am not allowed to use parameters.

My question is: What determines if a sql question can be displayed grafically?

Pleas enlighten me.

Mike



All times are GMT +1. The time now is 12:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com