You can research to find the more-or-less complete list of error codes and write code to trap specific ones, or you can purposely perform an action that will cause a specific error. Then you write an error handling routine and use either Case Select or IF block to present your custom message in a message box. No additional form is needed, unless you have the requirement for such. The are tons of examples on how to write these, so it doesn't make a whole lot of sense to provide an example here, especially if it isn't complex enough for your needs. What they will all have in common is that at the appropriate place(s) in your code, you will have a statement like On Error GoTo YourLineLabelNameHere. Usually that goes right after the Dim statements. Be sure your code includes an exit block that a) provides an exit point; b) closes/resets/destroys any objects you have created that exist only in the procedure this code is running from, or else code execution will move right into the error handler.
EDIT: forgot to mention that this is a vital part of a db that operates with a minimum of system generated error messages. You should try to anticipate as many user "mistakes" as possible and handle any that seem probable. For instance, you might try to enter text in a number field (or vice versa) or too many characters, or no data at all, etc. I'm assuming you're using vba code. I don't use macros and can't even tell you if the latest version has any error handling possibilities at all. Macros have never had error handling capabilities in the past.
Last edited by Micron; 05-12-2018 at 12:12 PM.
Reason: added info
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.