Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-03-2019, 05:41 PM   #1
EzGoingKev
Newly Registered User
 
Join Date: Nov 2019
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
EzGoingKev is on a distinguished road
IF Block with MsgBox and Submacro

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?

EzGoingKev is offline   Reply With Quote
Old 12-03-2019, 06:07 PM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,491
Thanks: 15
Thanked 4,148 Times in 4,079 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: IF Block with MsgBox and Submacro

You'll find very few of us use macros. Is converting to VBA an option?
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 12-03-2019, 06:24 PM   #3
EzGoingKev
Newly Registered User
 
Join Date: Nov 2019
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
EzGoingKev is on a distinguished road
Re: IF Block with MsgBox and Submacro

Quote:
Originally Posted by pbaldy View Post
You'll find very few of us use macros. Is converting to VBA an option?
Beyond my abilities.

EzGoingKev is offline   Reply With Quote
Old 12-03-2019, 06:32 PM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,491
Thanks: 15
Thanked 4,148 Times in 4,079 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: IF Block with MsgBox and Submacro

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
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 12-03-2019, 06:57 PM   #5
EzGoingKev
Newly Registered User
 
Join Date: Nov 2019
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
EzGoingKev is on a distinguished road
Re: IF Block with MsgBox and Submacro

I figured it out. There is a RunMacro function and that did the trick.
EzGoingKev is offline   Reply With Quote
Old 12-03-2019, 07:10 PM   #6
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 7,294
Thanks: 66
Thanked 1,685 Times in 1,640 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: IF Block with MsgBox and Submacro

Quote:
Originally Posted by EzGoingKev View Post
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.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 12-03-2019, 07:17 PM   #7
EzGoingKev
Newly Registered User
 
Join Date: Nov 2019
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
EzGoingKev is on a distinguished road
Re: IF Block with MsgBox and Submacro

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.

EzGoingKev is offline   Reply With Quote
Old 12-03-2019, 07:25 PM   #8
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 7,294
Thanks: 66
Thanked 1,685 Times in 1,640 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: IF Block with MsgBox and Submacro

Quote:
Originally Posted by EzGoingKev View Post
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!
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 12-03-2019, 07:56 PM   #9
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,491
Thanks: 15
Thanked 4,148 Times in 4,079 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: IF Block with MsgBox and Submacro

Glad you got it sorted.

__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running submacro in a loop a variable number of times Sdata Macros 10 11-21-2019 02:21 PM
[SOLVED] Block If without End IF jjake Modules & VBA 5 11-03-2016 11:09 AM
Block If without End If????? Firemansam Modules & VBA 5 01-07-2014 04:10 AM
New on the Block Viper210 Introduce Yourself 2 05-10-2012 09:59 AM
Block If Without End If? circlestech Modules & VBA 20 08-08-2006 11:33 AM




All times are GMT -8. The time now is 07:35 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World