Reputation: 3789
My code is as below
conDB.Execute strSQL, recordsAffected
Sheet1.Cells(intStart, 5) = IIf(recordsAffected > 0, "Success", "Failure")
Intread of printing failure i want to print the error description. I tried
Sheet1.Cells(intStart, 5) = IIf(recordsAffected > 0, "Success", Err.Des)
but it doesn't work. Any ideas?
Upvotes: 0
Views: 240
Reputation: 3881
The Err object has a value only after an error occurs. So try this
Sub MySub(strSQL as string)
On error goto CATCH
conDB.Execute strSQL, recordsAffected
Sheet1.Cells(intStart, 5) = IIf(recordsAffected > 0, "Success", "Hmm ?")
exit sub
CATCH:
Sheet1.Cells(intStart, 5) = Err.Description
on error goto 0
end sub
Upvotes: 1