Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Microsoft query won't allow parameters

I have a sql union query that works just fine but I want to let the user
choose a date in an excel field. When I input my sql code into microsoft
query I get the error:

'Parameters are not allowed in queries that can't be graphically displayed.'

I am looking for a solution to the above error.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Microsoft query won't allow parameters

kmoyer,
Build the SQL yourself and generate your own querytable or recordset
e.g.
Startdate=Inputbox("Enter date")
SQL="SELECT * FROM MyTable1 WHERE SDate=#" & Startdate & "#"
SQL=SQL & " UNION "
SQL=SQL & "SELECT * FROM MyTable2 WHERE SDate=#" & Startdate & "#"
RS.Execute SQL

NickHK

"kmoyer" wrote in message
...
I have a sql union query that works just fine but I want to let the user
choose a date in an excel field. When I input my sql code into microsoft
query I get the error:

'Parameters are not allowed in queries that can't be graphically

displayed.'

I am looking for a solution to the above error.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Microsoft query won't allow parameters

I am a little new at the microsoft query thing and maybe a little confused
with your solution as I still get the same error message but I may be doing
something wrong. Below is my query. When I use a fixed date like below I do
not get the error message but when I replace it with a ? microsoft query
yells at me.

SELECT t1.seg1_code, ABS(Sum(t1.current_balance))
FROM CCCI002.dbo.glbal t1, CCCI002.dbo.glchart t2
WHERE t1.account_code = t2.account_code AND (t1.balance_date=732311) AND
((t1.seg3_code Between 30000400 And 30000499)OR (t1.seg3_code Between
40000400 And 40000439)
OR (t1.seg3_code Between 50000400 And 50000439)
)
GROUP BY t1.seg1_code


UNION


SELECT t1.seg1_code, ABS(Sum(t1.current_balance))
FROM ccmidwst.dbo.glbal t1, ccmidwst.dbo.glchart t2
WHERE t1.account_code = t2.account_code AND (t1.balance_date=732311)and
((t1.seg3_code Between 30000400 And 30000499) OR (t1.seg3_code
Between 40000400 And 40000439) OR (t1.seg3_code Between 50000400 And
50000439))
GROUP BY t1.seg1_code
order by t1.seg1_code

Thanks
Kelly
"NickHK" wrote:

kmoyer,
Build the SQL yourself and generate your own querytable or recordset
e.g.
Startdate=Inputbox("Enter date")
SQL="SELECT * FROM MyTable1 WHERE SDate=#" & Startdate & "#"
SQL=SQL & " UNION "
SQL=SQL & "SELECT * FROM MyTable2 WHERE SDate=#" & Startdate & "#"
RS.Execute SQL

NickHK

"kmoyer" wrote in message
...
I have a sql union query that works just fine but I want to let the user
choose a date in an excel field. When I input my sql code into microsoft
query I get the error:

'Parameters are not allowed in queries that can't be graphically

displayed.'

I am looking for a solution to the above error.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Microsoft query won't allow parameters

kmoyer,
I mean use QueryTables.Add
The arguments are Connection, Destination As Range, [Sql].
So if your SQL is fully formed before you issue this, there should not be
any problem.
Looks like you would have do some conversion of the date value from Excel to
the that expected by your DB also.

NickHK

"kmoyer" wrote in message
...
I am a little new at the microsoft query thing and maybe a little confused
with your solution as I still get the same error message but I may be

doing
something wrong. Below is my query. When I use a fixed date like below I

do
not get the error message but when I replace it with a ? microsoft query
yells at me.

SELECT t1.seg1_code, ABS(Sum(t1.current_balance))
FROM CCCI002.dbo.glbal t1, CCCI002.dbo.glchart t2
WHERE t1.account_code = t2.account_code AND (t1.balance_date=732311) AND
((t1.seg3_code Between 30000400 And 30000499)OR (t1.seg3_code Between
40000400 And 40000439)
OR (t1.seg3_code Between 50000400 And 50000439)
)
GROUP BY t1.seg1_code


UNION


SELECT t1.seg1_code, ABS(Sum(t1.current_balance))
FROM ccmidwst.dbo.glbal t1, ccmidwst.dbo.glchart t2
WHERE t1.account_code = t2.account_code AND (t1.balance_date=732311)and
((t1.seg3_code Between 30000400 And 30000499) OR (t1.seg3_code
Between 40000400 And 40000439) OR (t1.seg3_code Between 50000400 And
50000439))
GROUP BY t1.seg1_code
order by t1.seg1_code

Thanks
Kelly
"NickHK" wrote:

kmoyer,
Build the SQL yourself and generate your own querytable or recordset
e.g.
Startdate=Inputbox("Enter date")
SQL="SELECT * FROM MyTable1 WHERE SDate=#" & Startdate & "#"
SQL=SQL & " UNION "
SQL=SQL & "SELECT * FROM MyTable2 WHERE SDate=#" & Startdate & "#"
RS.Execute SQL

NickHK

"kmoyer" wrote in message
...
I have a sql union query that works just fine but I want to let the

user
choose a date in an excel field. When I input my sql code into

microsoft
query I get the error:

'Parameters are not allowed in queries that can't be graphically

displayed.'

I am looking for a solution to the above error.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Query - 2 Parameters cottage6 Excel Discussion (Misc queries) 2 July 17th 08 09:16 PM
Query Parameters Texas_Toast Excel Discussion (Misc queries) 0 January 11th 06 03:14 PM
Microsoft Query rejects "nz" function in Access Query Vaughan Excel Discussion (Misc queries) 0 May 4th 05 05:20 PM
Web Query Parameters raboo2u Excel Programming 4 January 11th 04 08:54 PM
Query Parameters Jeff Excel Programming 1 November 18th 03 05:47 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"