By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Switches?? - Access 2002, VBA

P: n/a
I've used VBA before, but not to the extent that I'm looking at now.
I've been asked to do some modifications to a database that a former
employee created. She built all the forms with code, so I've got to
struggle to understand what she did before I can get on with the
modifications. In the code, she declares, sets and resets switches.
Can anyone tell me what switches are? Below are some examples of what
she wrote. Thank you in advance for your help.

'Declare Switches
Dim Valid_Entry As Boolean 'TRUE/FALSE switch
Dim Valid_SW As Boolean 'TRUE/FALSE switch
Dim Found_Sw As Boolean 'TRUE/FALSE switch
----------------------------------------------------------
'Set the switches to FALSE
Valid_Entry = False
Valid_SW = False
Found_Sw = False
----------------------------------------------------------
Valid_SW = True
----------------------------------------------------------
Found_SW = True
----------------------------------------------------------
'Reset the valid switch
Valid_SW = False
----------------------------------------------------------
'Reset the Found switch
Found_Sw = False
----------------------------------------------------------

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
jv
Those are simply boolean variables that you can create and use for any
purpose.

Nov 13 '05 #2

P: n/a
"jv" wrote
Those are simply boolean variables
that you can create and use for any
purpose.


To expand on this... for any purpose for which you need a Yes/No value. They
are often used to control the logic of code execution.

And, you have to determine, in context, what they are used for if there are
no comments explaining it. Obviously, there is code omitted, because without
something else, what you show would be nonsensical.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #3

P: n/a
Larry Linson wrote:
And, you have to determine, in context, what they are used for if there are
no comments explaining it. Obviously, there is code omitted, because without
something else, what you show would be nonsensical.


Maybe they're Flip-Flop switches. :-)

Here's TMGATMI (too much guesswork and too much information):

Larry's correct. Assuming you didn't have her write any documentation
regarding the software design you'll have to use the names of the
variables along with how they are used in the context of code to see
what they are used for. A boolean switch can be thought of as a
True/False signal (or flag) that something has or hasn't happened. It
looks like the switches are for search/edit forms. Found_Sw seems to
indicate whether or not a record was found. Valid_SW could be related
to proper/improper edits after the record is found. Valid_Entry could
indicate whether or not the edits got saved to the table. Go by what
conditions in code cause the values to change. When programming a
boolean switch in general, you usually decide first whether an initial
value of True or False will result in better code. The default for
input validation is usually False so that if any condition is not met
you can simply exit early without having to set a value. I think you
would save time and possibly money by hiring some short-term
programming help until you are over the initial hurdles, especially if
you have a lot of determination.

James A. Fortune

Nov 13 '05 #4

P: n/a
Thank you for your help.

ji********@compumarc.com wrote:
Larry Linson wrote:
And, you have to determine, in context, what they are used for if there are
no comments explaining it. Obviously, there is code omitted, because without
something else, what you show would be nonsensical.


Maybe they're Flip-Flop switches. :-)

Here's TMGATMI (too much guesswork and too much information):

Larry's correct. Assuming you didn't have her write any documentation
regarding the software design you'll have to use the names of the
variables along with how they are used in the context of code to see
what they are used for. A boolean switch can be thought of as a
True/False signal (or flag) that something has or hasn't happened. It
looks like the switches are for search/edit forms. Found_Sw seems to
indicate whether or not a record was found. Valid_SW could be related
to proper/improper edits after the record is found. Valid_Entry could
indicate whether or not the edits got saved to the table. Go by what
conditions in code cause the values to change. When programming a
boolean switch in general, you usually decide first whether an initial
value of True or False will result in better code. The default for
input validation is usually False so that if any condition is not met
you can simply exit early without having to set a value. I think you
would save time and possibly money by hiring some short-term
programming help until you are over the initial hurdles, especially if
you have a lot of determination.

James A. Fortune


Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.