Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MS Query - Parameter Bug

I have an Excel 2002 worksheet connected to a SQL Server 2000 database.
The data query is simply:
SELECT Count(*) FROM Orders WHERE SALE_DATE=[Parameter1]

When prompted for the parameter value, I can manually enter a date 6/20/2004 and the query executes perfectly.

But when I try to read a date vaule from a cell, I get an error message "data type mismatch". I have tried all date formats in the cell to no avail. The column SALE_DATE is a smalldatetime type.

It appears to be a bug in the Parameter global variable Microsoft uses to pass value from the sheet to the query. It works for integers and strings but not dates. There must be some crazy way of encapsulating the date value?

Any suggestions?

Thanks!!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MS Query - Parameter Bug

SELECT Count(*) FROM Orders WHERE SALE_DATE="'" & format( _
Range("Sheet1!A1").Value2,"dd mmm yyyy") & "'"

--
Regards,
Tom Ogilvy


"TedGrier" wrote in message
...
I have an Excel 2002 worksheet connected to a SQL Server 2000 database.
The data query is simply:
SELECT Count(*) FROM Orders WHERE SALE_DATE=[Parameter1]

When prompted for the parameter value, I can manually enter a date

6/20/2004 and the query executes perfectly.

But when I try to read a date vaule from a cell, I get an error message

"data type mismatch". I have tried all date formats in the cell to no avail.
The column SALE_DATE is a smalldatetime type.

It appears to be a bug in the Parameter global variable Microsoft uses to

pass value from the sheet to the query. It works for integers and strings
but not dates. There must be some crazy way of encapsulating the date
value?

Any suggestions?

Thanks!!!!



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
Parameter Query Lee Excel Discussion (Misc queries) 4 October 12th 09 07:38 PM
Parameter query in MS Query from Excel Jimbo Excel Discussion (Misc queries) 1 September 9th 09 04:27 PM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
How to choose if I use a parameter or not in a parameter query Arnaud Excel Discussion (Misc queries) 0 March 8th 07 01:19 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 03:48 PM.

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

About Us

"It's about Microsoft Excel"