Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am relatively new to this, so maybe I am overlooking something
simple. I am trying to run some queries via VB and can get most of them to work. However, when I use a Case when statment I get a type missmatch error. After copying the debug.print to my query analyzer or directly into Microsoft query, I don't have a problem. It's only when I run if from VB. Here is my code, if anyone can please help: stsql = "Set NoCount on " & _ "Select " & _ "CM.Certmainseqno , RefDate = CM.activitydate " & _ "Into #POL from DayOld..Commtrans as CM " & _ "where CM.activitydate = '06/01/04' and CM.commpayee = '33816230' " & _ "Set NoCount Off " & _ "Select Test = case when RefDate = '06/03/04' then RefDate else GetDate() end " & _ "From #Pol " With ActiveSheet.QueryTables.Add(Connection:="ODBC;DSN= Warehouse;Description=DataWarehouse Summary Database;DATABASE=Warehouse;UseProcForPrepare=0" _ , Destination:=Range("A1")) .CommandText = Array( _ stsql) .Name = "GetPols" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = True .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End With Everything works fine if I do not include the case statement. All records are returned if if have the last piece as select * from #Pol. Any help would be appreciated. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Type mismatch | Excel Programming | |||
Type mismatch | Excel Programming | |||
Type Mismatch | Excel Programming | |||
Type mismatch while running If statement | Excel Programming |