View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
wsummers wsummers is offline
external usenet poster
 
Posts: 2
Default Error Trapping when getting external Data

I am using the following statement to get external OBDC data for refreshing
an Excel 2003 pivot table:

Sheets("Source PivotTable").PivotTableWizard SourceType:=xlExternal,
SourceData:=Array( _
"SELECT *" & Chr(13) & "" & Chr(10) & "FROM Data Data" & Chr(13) &
"" & Chr(10) & "WHERE" _
, _
mySQLWhere1 _
, _
mySQLWhere2 & Chr(13) & "" & Chr(10) & "ORDER BY " _
, _
"Data.Material, Data.`Serial No`, Data.`Receive Date` DESC"), _
Connection:=Array(Array("ODBC;DSN=MS Access Database;DBQ=" & myPath
& myFileName & ";"), _
Array("DefaultDir=" & myPath & ";DriverId=25;FIL=MS
Access;MaxBufferSize=2048;"), _
Array("PageTimeout=5;"))

I need code to trap the VBA Error 1004 message I get when no data is found.
Does anyone have any suggestions?

Thanks
Will