Use VBA code to Replace other VBA code (1 Viewer)

Thicko

Registered User.
Local time
Today, 01:37
Joined
Oct 21, 2011
Messages
61
Hi All,

In brief I need to press a button that will disable the MsgBox's, then I need the database to run through a large set of test data to check the output.

In normal circumstances the operator would be present, but for testing I just need to run the data and review the results without it stopping at every msgbox .

Manually I'd use the Replace tool in VBA to do MsgBox --> 'Validation'MsgBox. Because we do this several times a year after updates etc.. I need a more robust (non human) method to switch off MsgBox's then run code then switch MsgBox's back on.

All thoughts welcome, a search shows a few options but these relate to excel vba and not access.

Many Thanks
Thicko
 

isladogs

MVP / VIP
Local time
Today, 01:37
Joined
Jan 14, 2017
Messages
18,186
You could use a boolean variable for this:

Place this in a standard module:
Code:
Public blnHideMessages As Boolean

Add this code to your button click:
Code:
blnHideMessages=True

Then wherever you have a message you want to hide, modify code to:
Code:
If blnHideMessages=False Then MsgBox"Your message here ..."

If you do this, you may want to add code to toggle the boolean back to false
Otherwise that will happen when the app is restarted

If you have a huge number of messages to disable you may prefer to setup a function to do the same
Swings and roundabouts really in terms of time needed...
 

Thicko

Registered User.
Local time
Today, 01:37
Joined
Oct 21, 2011
Messages
61
Thank you both, I think that would work and what Isladogs suggests will be easy to switch on and off.
 

isladogs

MVP / VIP
Local time
Today, 01:37
Joined
Jan 14, 2017
Messages
18,186
You're welcome
Actually all you'll need to do is a Find & Replace in the VBE
Find: MsgBox
Replace: If blnHideMessages=False Then MsgBox
 

Users who are viewing this thread

Top Bottom