I have an Access 2000 project that uses SQL 2000 sp's to read and write to my SQL tables. They work great. My problem is that I cannot get my VBA Access code in the (client side) project to receive the @@error global variable value that the sp sends when a runtime error occurs (in the sp). In the interest of brevity, the end of my sp code is:
xxxx......
Select @intErrorCode = @@ERROR
End
IF @intErrorCode = 0
COMMIT TRANSACTION
Else
ROLLBACK TRANSACTION
Return @intErrorCode
My problem occurs when I do the cmd.Execute in my project. If a sp generates a runtime error, the VBA code stops at the cmd.Execute, then a system generated error message box appears. The end of my VBA project code that calls the sp is:
xxxxxx....
cmdAddName.Parameters.Append cmdAddName.CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue)
xxxx......
xxxx...... etc., etc.
cmdAddName.Execute
Beep
varErrorCode = cmdAddName.Parameters("RETURN_VALUE").Value
If varErrorCode = 99 Then
Beep
Beep
MsgBox "Error occurred.", 16, "System message"
Exit Sub
Else
.........
The program never runs to my code that receives the RETURN_VALUE so I can provide the user a more fiendly message. It always stops at the cmd.Execute. Anyone know why the sp runtime error causes the Access VBA code to stop at the cmd.Execute command?
Thanks for any help you can proivde.
xxxx......
Select @intErrorCode = @@ERROR
End
IF @intErrorCode = 0
COMMIT TRANSACTION
Else
ROLLBACK TRANSACTION
Return @intErrorCode
My problem occurs when I do the cmd.Execute in my project. If a sp generates a runtime error, the VBA code stops at the cmd.Execute, then a system generated error message box appears. The end of my VBA project code that calls the sp is:
xxxxxx....
cmdAddName.Parameters.Append cmdAddName.CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue)
xxxx......
xxxx...... etc., etc.
cmdAddName.Execute
Beep
varErrorCode = cmdAddName.Parameters("RETURN_VALUE").Value
If varErrorCode = 99 Then
Beep
Beep
MsgBox "Error occurred.", 16, "System message"
Exit Sub
Else
.........
The program never runs to my code that receives the RETURN_VALUE so I can provide the user a more fiendly message. It always stops at the cmd.Execute. Anyone know why the sp runtime error causes the Access VBA code to stop at the cmd.Execute command?
Thanks for any help you can proivde.