Yes. Look up the concept of "Error Handler." The overview is that every error with Access has a number which is returned via the Err object, a built-in part of the Access environment. When an error is declared, the error handler is activated. Within the error handler, you can check Err.Number to see if it is the number that is returned for a validation violation and can choose to put up a message box, then resume execution in some appropriate location. If it happens that the error was not the one you expected, you have other possibilities including the choice to resignal the error and let Access handle it - but that would be another case where the user would see the error and Access would try to open a code segment. Note that if you use error handlers, they are like program interrupts and you need to be sure to properly dismiss them. It's not hard to do so, it is just that you need to remember to do so.
Here is a link to an article on error handlers. It is a decent place to start.
Office VBA reference topic
learn.microsoft.com
Error handlers can get complicated if you reasonably expect more than one type of error with different options.