IF Block with MsgBox and Submacro (1 Viewer)

EzGoingKev

Registered User.
Local time
Today, 19:24
Joined
Nov 8, 2019
Messages
178
I have an IF block in a macro.

In the IF block is MsgBox("Check Data", 4)=6. If you hit yes it opens a form.

I have the form set to run a submacro when you close it.

The Submacro is in the same macro after the IF block. I thought if I select no in the IF block it would go on to run the submacro but it does not.

What do I need to get the macro to run the submacro?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 16:24
Joined
Aug 30, 2003
Messages
36,118
You'll find very few of us use macros. Is converting to VBA an option?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 16:24
Joined
Aug 30, 2003
Messages
36,118
Well, if you post the design view of the macro, maybe somebody will see something to fix it.

If you're interested in learning VBA, there is a built-in macro converter. With a macro in design view there should be a ribbon icon "Convert macros to VBA". I think in earlier versions it was in the file menu. That will create a function, which normally isn't appropriate, but you can copy/paste the code from there to an event procedure:

http://www.baldyweb.com/FirstVBA.htm
 

EzGoingKev

Registered User.
Local time
Today, 19:24
Joined
Nov 8, 2019
Messages
178
I figured it out. There is a RunMacro function and that did the trick.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:24
Joined
Oct 29, 2018
Messages
21,358
I figured it out. There is a RunMacro function and that did the trick.
Hi. That is interesting; although probably not surprising, to call a macro within a macro to run while in the same macro. I suppose the same thing is also happening in VBA, in a way.
 

EzGoingKev

Registered User.
Local time
Today, 19:24
Joined
Nov 8, 2019
Messages
178
To me the funny thing is that if you run that IF block with the MsgBox and you do not tell it to stop it will go on and do other things after the block. When it hits the submacro it just stops.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:24
Joined
Oct 29, 2018
Messages
21,358
To me the funny thing is that if you run that IF block with the MsgBox and you do not tell it to stop it will go on and do other things after the block. When it hits the submacro it just stops.
Probably (just a guess) because it's an implied Stop Macro when you start a new macro definition within a macro. But just like Paul said earlier, I too don't use macros very much. Cheers!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 16:24
Joined
Aug 30, 2003
Messages
36,118
Glad you got it sorted.
 

Users who are viewing this thread

Top Bottom