I have a SQL Server table with a trigger after insert, update, and delete. If a certain condition is found, the trigger rolls back the transaction and raises a custom error using raise error. I've verified it works properly. The basic idea is that during such times as I need to "freeze" all record updating, I will execute a stored procedure that simply places a value in a SQL table that indicates the "freeze" is turned "on". The trigger will look at that, and if turned on, and if SQL current_user is not me or admin, then roll back, raiseerror, etc.
In MS Access, I was hoping to utilize this and only this in order to communicate back to the users. Meaning, for example, I realize I could totally re-structure this method and have MS Access "look up" that value (if freeze is 'on') every time a record is updated... but
1) that would mean identifying a LOT of places where the Access app gives the user a method to update a record, and write dlookup() code all over, and
2) that would mean the slowness of a dlookup, and I don't need to add any slowness to this app.
I wanted to be a "good boy" and handle this on the server side. Admirable, right?? I know.
My problem is trapping the custom SQL error in Access.
I read this: https://social.msdn.microsoft.com/Fo...orum=accessdev
... and tried Dirk's method of using the DAO.Errors collection. Unfortunately what I think I have found out is that that entire method only works if you have actually triggered the error using DAO (vba). (which makes sense). NOT, if an error has occurred that was form-based and not necessarily having used DAO in code.
Does anyone know of a way to trap the SQL server error in MS Access? And not just get "odbc - update on a linked table failed" (or Call Failed, etc etc).
My last option will be to create custom error handling in the Access app that looks up the record in the SQL table to see if the freeze is on, but only does this in an error handling routine that sees if we are getting a cruddy vague "odbc-update..." type of error description in the first place.
But this will still involve the hope that I identify all places in the app that does the update.