Return value from running a sql statement

I have a SQL statement and a stored procedure that I want to throw a message depending on the success of it. What is the syntax

I thought it was the following:

Dim result as Boolean

result = docmd.runsql " [SQL Statement/Stored procedure]"

If result Then

Msgbox ("success")

Else

MsgBox Err.Description & " " & Err.Number

End If

Please help jog my memory.



Answer this question

Return value from running a sql statement

  • ALZDBA

    Hi Nova

    Try the below this redirects the code if an error occurs. It will not warn you if there is no error and the statement does not do what you expect. With out knowing what the SQL statement does its hard to say how to check if it performed as desired. (I am assuming this code is in a sub routine)

    On Error GoTo Errhandler

    docmd.runsql " [SQL Statement/Stored procedure]"

    Exit Sub

    ErrHandler:

    MsgBox Err.Description & " " & Err.Number

    End Sub

    Hope this helps


  • Return value from running a sql statement