Morning all,

I have code that runs a sql statement to grab data for my worksheet, the sql statement runs fine but if it returns nothing (because of an empty table) it gives an error and ends. I need it to just skip to the next sql. Here's the code....any help would be greatly appreciated.

sSQL = "SELECT config_char.config_char_sc, config_char.config_char_n, config_char.config_char_rmk" & _
       " FROM config_char" & _
       " WHERE (config_char.stat_flag = 'n') AND (config_char.config_char_id > 0)"
 
Set oRS = oCN.Execute(sSQL)

'Move pointer back to start of data range
oRS.movefirst
Do While Not oRS.EOF
   ActiveCell.Value = oRS.Fields("config_char_sc").Value
   ActiveCell.Offset(0, 2).Select
   ActiveCell.Value = oRS.Fields("config_char_n").Value
   ActiveCell.Offset(0, 2).Select
   ActiveCell.Value = oRS.Fields("config_char_rmk").Value
   ActiveCell.Offset(1, -4).Select
   oRS.movenext
Loop

'*****end config_char export
'*****start cost_types export SDK
Sheets("Cost Types").Select
Range("A9").Select

'iReply = MsgBox(Prompt:="Overwrite current data with exported data?", _
        Buttons:=vbYesNoCancel, Title:="Export Data")
        
If iReply = vbYes Then
    Call Del_CostTypes
    Sheets("Cost Types").Select
    Range("A9").Select

ElseIf iReply = vbNo Then
    Sheets("Cost Types").Select
    Range("A9").Select
    While ActiveCell.Value <> ""
        ActiveCell.Offset(1, 0).Select
    Wend
    
Else 'They cancelled (VbCancel)
    Exit Sub
End If


sSQL = "SELECT cost_type.cost_type_sc, cost_type.cost_type_n, cost_type.cost_type_rmk" & _
       " FROM cost_type" & _
       " WHERE (cost_type.stat_flag = 'n') AND (cost_type.cost_type_id > 0)"
 
Set oRS = oCN.Execute(sSQL)
If Not oRS.EOF Then
    oRS.movefirst
End If

'Move pointer back to start of data range
oRS.movefirst
Do While Not oRS.EOF
   ActiveCell.Value = oRS.Fields("cost_type_sc").Value
   ActiveCell.Offset(0, 2).Select
   ActiveCell.Value = oRS.Fields("cost_type_n").Value
   ActiveCell.Offset(0, 2).Select
   ActiveCell.Value = oRS.Fields("cost_type_rmk").Value
   ActiveCell.Offset(1, -4).Select
   oRS.movenext
Loop
Thanks in Advance,
Di