Unable to parameters in MicrosoftQuery

C

Captain Query

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
 
J

Joel

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

Jim Thomlinson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top