Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I insert a macro into a boolean statement Garrett Excel Worksheet Functions 1 December 29th 05 03:46 PM
Worksheet_Change sub does not trigger a called macro herman Excel Programming 3 February 8th 04 08:30 PM
Keeping name of worksheet who called macro Dkline[_2_] Excel Programming 3 January 30th 04 06:40 PM
Sending email via macro- setting the importance setting. Julian Milano[_2_] Excel Programming 1 January 20th 04 10:15 PM
which FormField called a macro? Juggernath[_2_] Excel Programming 0 January 15th 04 12:58 PM


All times are GMT +1. The time now is 05:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"