Setting a boolean depending on who called the macro
I have a subroutine called "FileAll". There are three other subroutines that
can call it: "CreateFileAndParameters", "FullInput", and "CreateFile". The "FileAll" can also be called directly by a command button. So there are four ways that the "FileAll" routine gets invoked - directly by a command button or from three other macros. Within the "FileAll" I now have a UserForm to ask if an additional subroutine be run. I only want to have the UserForm to NOT appear if the user selected "FullInput". "FullInput" runs a loop which includes "FileAll" and I don't want the user to have to sit there and respond to a dialogue each time through the loop. So I created a pair of Public booleans: blnAddToInventory 'set by the userform to indicate if the additional routine is to run blnAddToInventoryRun 'set to show or not show the userform I believe I have to initialize the "blnAddToInventoryRun" in the "FileAll" macro to TRUE since it used by 3 of 4 ways of starting the "FileAll" including "FileAll" being called by the command button. How can I change the initialized value of blnAddToInventoryRun if the user starts from the "FullInput" macro? |
Setting a boolean depending on who called the macro
Change the sense of your thinking. You only do not show the form if the
boolean is true Public bNoFormShow as Boolean Sub FullInput() ' code bNoFormShow = True FileAll bNoFormShow = False End Sub Sub File All ' code if Not bNoFormShow then userform1.Show End if End Sub The default value of bNoFormShow will be False, so only set it to true when you don't want to show the form. Since the only case where you want this to happen is from the code FullInput - this gives you the opportunity to set it. -- Regards, Tom Ogilvy "Dkline" wrote in message ... I have a subroutine called "FileAll". There are three other subroutines that can call it: "CreateFileAndParameters", "FullInput", and "CreateFile". The "FileAll" can also be called directly by a command button. So there are four ways that the "FileAll" routine gets invoked - directly by a command button or from three other macros. Within the "FileAll" I now have a UserForm to ask if an additional subroutine be run. I only want to have the UserForm to NOT appear if the user selected "FullInput". "FullInput" runs a loop which includes "FileAll" and I don't want the user to have to sit there and respond to a dialogue each time through the loop. So I created a pair of Public booleans: blnAddToInventory 'set by the userform to indicate if the additional routine is to run blnAddToInventoryRun 'set to show or not show the userform I believe I have to initialize the "blnAddToInventoryRun" in the "FileAll" macro to TRUE since it used by 3 of 4 ways of starting the "FileAll" including "FileAll" being called by the command button. How can I change the initialized value of blnAddToInventoryRun if the user starts from the "FullInput" macro? |
Setting a boolean depending on who called the macro
I think this is the answer to your question.
modulename.variablename = true modulename.variablename = false "Dkline" wrote in message ... I have a subroutine called "FileAll". There are three other subroutines that can call it: "CreateFileAndParameters", "FullInput", and "CreateFile". The "FileAll" can also be called directly by a command button. So there are four ways that the "FileAll" routine gets invoked - directly by a command button or from three other macros. Within the "FileAll" I now have a UserForm to ask if an additional subroutine be run. I only want to have the UserForm to NOT appear if the user selected "FullInput". "FullInput" runs a loop which includes "FileAll" and I don't want the user to have to sit there and respond to a dialogue each time through the loop. So I created a pair of Public booleans: blnAddToInventory 'set by the userform to indicate if the additional routine is to run blnAddToInventoryRun 'set to show or not show the userform I believe I have to initialize the "blnAddToInventoryRun" in the "FileAll" macro to TRUE since it used by 3 of 4 ways of starting the "FileAll" including "FileAll" being called by the command button. How can I change the initialized value of blnAddToInventoryRun if the user starts from the "FullInput" macro? |
Setting a boolean depending on who called the macro
Thank you. Works first time every time.
"Tom Ogilvy" wrote in message ... Change the sense of your thinking. You only do not show the form if the boolean is true Public bNoFormShow as Boolean Sub FullInput() ' code bNoFormShow = True FileAll bNoFormShow = False End Sub Sub File All ' code if Not bNoFormShow then userform1.Show End if End Sub The default value of bNoFormShow will be False, so only set it to true when you don't want to show the form. Since the only case where you want this to happen is from the code FullInput - this gives you the opportunity to set it. -- Regards, Tom Ogilvy "Dkline" wrote in message ... I have a subroutine called "FileAll". There are three other subroutines that can call it: "CreateFileAndParameters", "FullInput", and "CreateFile". The "FileAll" can also be called directly by a command button. So there are four ways that the "FileAll" routine gets invoked - directly by a command button or from three other macros. Within the "FileAll" I now have a UserForm to ask if an additional subroutine be run. I only want to have the UserForm to NOT appear if the user selected "FullInput". "FullInput" runs a loop which includes "FileAll" and I don't want the user to have to sit there and respond to a dialogue each time through the loop. So I created a pair of Public booleans: blnAddToInventory 'set by the userform to indicate if the additional routine is to run blnAddToInventoryRun 'set to show or not show the userform I believe I have to initialize the "blnAddToInventoryRun" in the "FileAll" macro to TRUE since it used by 3 of 4 ways of starting the "FileAll" including "FileAll" being called by the command button. How can I change the initialized value of blnAddToInventoryRun if the user starts from the "FullInput" macro? |
All times are GMT +1. The time now is 07:26 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com