Re: Boolean variable not holding state
- From: Bob Quintal <rquintal@xxxxxxxxxxxxx>
- Date: Fri, 16 May 2008 19:14:02 -0400
"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in
news:u2mBXrntIHA.4912@xxxxxxxxxxxxxxxxxxxx:
"Bob Quintal" <rquintal@xxxxxxxxxxxxx> wrote in messageThanks for the explanation. I've always defined my parameters using
news:Xns9A9EC6666D5B8BQuintal@xxxxxxxxxxxxxxx
"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in
news:ejE5vSgtIHA.4772@xxxxxxxxxxxxxxxxxxxx:
You've declared validate inside of btnSaveRecord_Click. ThatEven with Option Explicit the sub does not generate any error.
means you can only refer to that variable inside that routine.
To declare a variable that can be used by all routines within
the module, declare the variable at the top of the module before
any code.
The fact, though, that you're not getting an error implies that
you haven't told Access to require that all variables be
declared. Go into the VB Editor and select Tools | Options from
the menu. Make sure that the "Require Variable Declaration" box
is checked on the Editor tab. If you had done that, then you'd
have quickly realized that your sub validateAccount knew nothing
about the variable validate.
The reason he's not getting an error is that he's used the
implicitly defined variant validate in the function by treating
it as a parameter.
The actual problem is that he's put validate inside parentheses,
and I don't know why, but that seems to prevent the call from
changing the variable
'This works:
validateAccount validate
'This does not:
validateAccount (validate)
Sorry, you're right Bob. I missed the fact that he was calling the
second sub from the first.
The reason it doesn't work is that putting parentheses around the
argument changes how you pass from the default ByRef to ByVal.
Using
Call validateAccount(validate)
would also work.
the ByVal keyword when I need to protect the source variable.
--
Bob Quintal
PA is y I've altered my email address.
** Posted from http://www.teranews.com **
.
- References:
- Boolean variable not holding state
- From: Jordan C. Schroeder
- Re: Boolean variable not holding state
- From: Douglas J. Steele
- Re: Boolean variable not holding state
- From: Bob Quintal
- Re: Boolean variable not holding state
- From: Douglas J. Steele
- Boolean variable not holding state
- Prev by Date: Re: Open form Order based on IDCustomer on new record
- Next by Date: Re: More 2007 Ribbon Issues
- Previous by thread: Re: Boolean variable not holding state
- Next by thread: Re: Boolean variable not holding state
- Index(es):
Relevant Pages
|