Solved VBA code, etc. to disable MS Access Debug Message Box (1 Viewer)

Local time
Today, 05:01
Joined
Jun 3, 2022
Messages
38
Hello! There is a form that will be completed by users. Four text boxes/Combo boxes that require the user to enter information. They'll hit save record command button and it'll save to the subform/table. But the issue is a user decides to only complete two text boxes, on purpose, and leaves the others empty, hits save button, a "Debug" message appears because obviously all the fields are not complete.

Besides the DeBug Message box opening up, which i would like to disable for users not to see the VBA code or change anything, is there a possible method for Ms access to display a message on the screen saying "Enter All Fields in Form" besides the DeBug message opening?

Conducting a dummy user test for this cilent project. I am assuming i would have to individually go into each text box and make a change or some VBA code in the background to disable the MS Access Debug Message.

Thanks!
 

Isaac

Lifelong Learner
Local time
Today, 03:01
Joined
Mar 14, 2017
Messages
8,738
There are so many things wrong here ... but let me start by saying the solution is to always password-protect your deployed, in-production vba projects. Fundamental basic! Then they can't click 'debug' and destroy your code
 
Local time
Today, 05:01
Joined
Jun 3, 2022
Messages
38
There are so many things wrong here ... but let me start by saying the solution is to always password-protect your deployed, in-production vba projects. Fundamental basic! Then they can't click 'debug' and destroy your code
There are many things wrong with this database that got thrown into my lap. Trying to break it down bit by bit for this client to be satisfied.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:01
Joined
Sep 21, 2011
Messages
14,050
You should be supplying a accde or accdr?
YOU need to validate the data that is required.
This has been asked many times on here. Do a search.
You should also be supplying user friendly error messages and error handling for unexpected events.
 

GPGeorge

Grover Park George
Local time
Today, 03:01
Joined
Nov 25, 2004
Messages
1,776
Hello! There is a form that will be completed by users. Four text boxes/Combo boxes that require the user to enter information. They'll hit save record command button and it'll save to the subform/table. But the issue is a user decides to only complete two text boxes, on purpose, and leaves the others empty, hits save button, a "Debug" message appears because obviously all the fields are not complete.

Besides the DeBug Message box opening up, which i would like to disable for users not to see the VBA code or change anything, is there a possible method for Ms access to display a message on the screen saying "Enter All Fields in Form" besides the DeBug message opening?

Conducting a dummy user test for this cilent project. I am assuming i would have to individually go into each text box and make a change or some VBA code in the background to disable the MS Access Debug Message.

Thanks!
First, you can write validation code to check for values in required fields and provide user-friendly feedback as you describe. You do that in the Before Update event of the form, or in the Before Update events of each control. I tend to think the Form level validation is most user friendly.

Search for posts on form validation for examples.

Second, you can increase the level of difficulty for people who might want to mess about in your code by delivering an accde and/or a password protected VBA project. I am of the opinion that the great majority of people do NOT look at their job as an opportunity to create problems for others, rather they go to work every day hoping to do good and earn rewards. So the concern over someone illicitly entering and altering my VBA is pretty low. I always provided a master copy of the FE anyway, just in case someone accidently changed the wrong thing and needed a fresh copy of it, but that was the extent in most instances. Besides, if users can't be trusted, the problem is on a much larger scale than this accdb.

If you are concerned about it, deploy the accde and make sure you have adequate error handling in place, such as the required fields validation mentioned above.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:01
Joined
Oct 29, 2018
Messages
21,358
Hi. As was already mentioned, you can provide your own error handler to replace the one Access invokes. That way, you can either display your own message or do something else entirely, instead of the user seeing the Debug button.
 

jdraw

Super Moderator
Staff member
Local time
Today, 06:01
Joined
Jan 23, 2006
Messages
15,364
I'm not sure how this database application got thrown in your lap, but have to ask "What did that person give you as far as "marching orders to accomplish what?"
"But the issue is a user decides to only complete two text boxes, on purpose, and leaves the others empty, hits save button, a "Debug" message appears because obviously all the fields are not complete." This is not a user option. If all fields must be completed, then all are completed or an error is displayed with info on what is needed to make this error go away.
It can't be "sometimes I accept or it isn't always required...
"

What are the business rules that this datbase is intended to support?


Others have posted while I was typing. I agree with suggestions provided in those posts.
 
Last edited:

Isaac

Lifelong Learner
Local time
Today, 03:01
Joined
Mar 14, 2017
Messages
8,738
There are many things wrong with this database that got thrown into my lap. Trying to break it down bit by bit for this client to be satisfied.
I understand, didn't mean it personal just a comment. Definitely never have a db in production that has an unprotected vba project.
As Gasman stated .accde, .accdr (etc) are better longer term options but before you even finish reading this post, get a PW on there!

Although I agree with @GPGeorge about most people's intentions, that Debug window is awfully easy to hit enter or space bar - and then hit it again - for fast (or careless) keyboarders...It's quite possible for your code to be messed up by a couple Enter keys before they even realize what they're doing. I password protect my OWN ad-hoc stuff because even I have done that to my own, accidentally.
Just hitting Enter twice (something they may be used to doing reflexively on pop-ups), and your code is now edited - and may even become corrupted due to how much VBA doesn't appreciate code being edited while in Break mode.
 

Users who are viewing this thread

Top Bottom