If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > excel sql query type mismatch error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-18-04, 10:47
nmci_dmar nmci_dmar is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
excel sql query type mismatch error

Hello All,

I am running a VBA Module in excel to grab data from a SQL Server. I am running into a Type Mismatch error in my where clause. If I try and have more that 2 or 3 where clauses it dies. The problem is I have up to 60 Where Clauses to pass. I am searching for a staus and base clause for 60 bases. Here is my Code

With Sheet10.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=Remedy;ARServer=" & server & ";ARServerPort=XXXX;UID=" & UserName & ";PWD=" & password & ";ARAuthentication=;ARDiaryDescend=1;ARUseUn" _
), Array("derscores=1;ARNameReplace=1;SERVER=NotTheSe rver")), Destination:=Sheet10.Range("A2"))
.CommandText = Array( _
"SELECT HPD_HelpDesk.Create_Time, HPD_HelpDesk.Case_ID_, HPD_HelpDesk.Status, HPD_HelpDesk.Escalated_, HPD_HelpDesk.Base, HPD_HelpDesk.Assigned_To_Group_, HPD_HelpDesk.Category, HPD_HelpDesk.Type, HPD_HelpDesk.Item," _
, _
" HPD_HelpDesk.Machine_Name_, HPD_HelpDesk.Description, HPD_HelpDesk.Work_Log, HPD_HelpDesk.Requester_Name_, HPD_HelpDesk.Phone_Number, HPD_HelpDesk.Building, HPD_HelpDesk.Floor, HPD_HelpDesk.Room_Cube, HPD_HelpDesk.Network_Jack" & Chr(13) & "" & Chr(10) & "FROM HP" _
, _
"D_HelpDesk HPD_HelpDesk" & Chr(13) & "" & Chr(10) & "WHERE (HPD_HelpDesk.Status<='Resolved') AND (HPD_HelpDesk.Base= 'ABNY') OR (HPD_HelpDesk.Status<='Resolved') AND (HPD_HelpDesk.Base= 'ADLP')" & Chr(13) & "" & Chr(10) & "ORDER BY HPD_HelpDesk.Case_ID_")
.Name = "Query from AR System ODBC Data Source"
.FieldNames = False
.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


It works like this but if I put any more Status and base where clauses it will die with a type mismatch. Please help.....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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