Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking SQL INSERT INTO return or error code

Status
Not open for further replies.

kdre

Programmer
Mar 2, 2001
8
0
0
US
Hi,

I want to check the success/failure of an INSERT INTO statement. I've checked 'ERR' but this does not pick up the status of the SQL statement itself. I have done this against other databases using different languages, but cannot find the code or reserved word to check this.

Below is the INSERT code. I want to check the return status and handle errors appropriately.


dbs.Execute "INSERT INTO Inventory" _
& "(bondnumber, prefixbond, numbond, agency, searchstatus)" _
& "VALUES (" _
& "'" & Me.tb_addfrom.Value & "'," _
& "'" & ls_prefix & "'," _
& ls_numbond & "," _
& gs_agency & "," _
& "'" & "INVENTORIED" & "'" & ");"

Thanks in advance for any advice!

Kathy
 
Errors that occur during execution of SQL code are stored in the DBEngine.Errors collection. Multiple errors can occur on a single SQL statement, so they are accumulated in a collection. The Access Help file contains information about the Errors collection and Error object. Rick Sprague
 
Thank you, Rick. I"ll check it out. I did check Access help but not under the topics you suggest.

Kathy
 
MichaelRed,

I am aware that link is broken.. It wasn't supposed to be part of my message, but I pasted it in by mistake!! Must not have had enough caffiene in my system at that time.

Kathy
 
Kathy,

You can "Red Falg" the messsage. In the pop up which follows the action, state the thinggggyyy you want changed.

Ipso presto, the friendlyfolks@Tek-Tips.com will go fix it for you.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top