How to build an If/then /else statements with multiple conditons
From: Elvira S. (anonymous_at_discussions.microsoft.com)
Date: 03/01/04
- Next message: ctdak: "Recordset FindFirst"
- Previous message: ES: "can't stop the beeping !"
- In reply to: Kathy: "How to build an If/then /else statements with multiple conditons"
- Next in thread: anonymous_at_discussions.microsoft.com: "How to build an If/then /else statements with multiple conditons"
- Reply: anonymous_at_discussions.microsoft.com: "How to build an If/then /else statements with multiple conditons"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Mar 2004 15:00:46 -0800
Hi Kathy,
I'd start by looking at the Help menu for If...then
statement. I'm not sure how easy a file it is to find on
the help menu but if you use the office assistant, you can
ask it "If then else statement" and that should take you to
the correct file.
About macros, I'm not sure which version of Access you're
using but macros are more or less outmoded. The main
reason they are still present in later in versions of
Access is for backward compatibility. I don't know anyone
who would recommend using them at this point.
VB is your best bet. It also gives you the option of using
a Select Case Statement, instead of If..Then, if you have
a lot of conditions to deal with.
The If..Then sytax is:
If Condition Then
code to execute goes here
ElseIf AnotherCondition Then
code to execute goes here
Else
code to execute goes here
End If
The Conditions can deal with various things. For instance,
if you want to base your If..Then structure on the value
entered in a control on a form, you might have:
If Me.ctlName Is Null Then....
or it might be a variable you're testing:
If (varName) Not IsNull Then
You can also link your conditions together with operators
like "And" and "Or" and also comparative operators like >=,
Like, Between, etc.
The trouble is that If..Then's with lots of conditions can
be become very confusing to read. That's where Select Case
comes in.
Again, I recommend the Access Help on Select Case.
Also, another useful thing is that you can combine Select
Case and If...Then constructs.
If you need specific help, reply with a description of your
scenario.
Good Luck!
Elvira
>-----Original Message-----
>Hi,
>I am trying to build an If/Then/Else statement with
>several conditions. I took VB several years ago and have
>not used it since the class. Can you recommend a tutorial
>or book etc. that would provide a simple explanation of
>how to build this kind of statement.
>Also I just want to be sure that I should be building a
>module and not a macro for these types of functions?
>
>Thanks so much,
>Kathy
>.
>
- Next message: ctdak: "Recordset FindFirst"
- Previous message: ES: "can't stop the beeping !"
- In reply to: Kathy: "How to build an If/then /else statements with multiple conditons"
- Next in thread: anonymous_at_discussions.microsoft.com: "How to build an If/then /else statements with multiple conditons"
- Reply: anonymous_at_discussions.microsoft.com: "How to build an If/then /else statements with multiple conditons"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|