Checking Error Codes after executing a SQL query

R

rich

Hello,

Is there a way to check for error codes or condition codes that indicate the
result of a SQL statement?

For example, if executing a query to search for a specific record based on
an ID number, is there some code that can be checked to determine the result
of the query? If a row is found, the code may be set to 100. If no row is
found, the code is set to 0. Are there other ways to check for various types
of conditions?

I know that VB has Err object. Can this be used?

TIA,
Rich
 
K

Klatuu

If you are using DAO and the Execute Method, you can use the RecordsAffected
property of CurrentDb.

With CurrentDb
.Execute("DELETE * FROM SomeTable;"), dbFailOnError
MsgBox .RecordsAffected & " Where Deleted"
End With

Including the dbFailOnError will throw an error if there is an execution
problem with the query. Include an error handler to trap them just as you
would for Access errors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top