Re: if-andif-then statement - need help

Tech-Archive recommends: Speed Up your PC by fixing your registry



Susan,
Show us the code where you trying to use blnFirst. It may be that you are
declaring command subroutines or the variables 'Private', instead of
'Public' (which narrows the 'scope' of their variable usage to just that
subroutine.) Or that you should declare the boolean variable in the
(Declarations) section of your project like these two lines...
Option Explicit
Public blnFirst As Boolean
.... In order for the 'scope' of the variable to be more 'global' (to be able
to be seen by all subroutines.)
Read about 'scope' of variables in VBA Help.
thanks russ & jim........
got that variable done correctly.
also figured out the if-endif issue.

please forgive my denseness on the boolean value - 1st time using it.
in the initializing i did blnFirst=True.
i also HAD to enter blnFirst=True at the beginning of my command macro,
because if i don't, it doesn't pick up on the statement:
You don't want it at the beginning of the command macro that you are testing
it in, because each time it goes through that macro and not just the first
time it is going to equate to True in your test. See the issue about scope
above.
So in order for this technique to work, it must be set to True in the
userform initialization subroutine; and tested and subsequently set to False
in your other userform command button subroutine. Then since it is never set
to True in the command button subroutine, after the first time through, the
command button test will always read as False when you click on the button.
Do you see the logic in doing it this way?
If .chkAHC.Value = True And blnFirst = True Then
Set it to False right after this line to make sure it gets done immediately
after the testing and is flipped from True to False. You don't want to
accidentally put after a Else or ElseIf clause unless you intend to do so in
the logical flow of your subroutine.
i tested this several times.

near the bottom of this if-then indented section, i added
blnFirst=False.
however, when it restarts & runs from the top again, it sets it back to
true.
please help me understand what i'm doing wrong.
thank you
susan


--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

.


Quantcast