If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA Code Help
Hello. Thanks for the help.
I have a form where I am using an if/then code to open a subform. Example: If Color = "Red" Then Do this ElseIf Color ="Blue" Then Do This ElseIf 'Any other...... I want to know if there is a way to make one of my ElseIf selections have more than one option. Something like: If Color = "Red" Then Do this ElseIf Color = "Blue" Then Do This ElseIf Color = "Orange" Or "Purple" Or "Yellow" Do This Thanks Again. |
#2
|
|||
|
|||
VBA Code Help
ElseIf Color = "Orange" Or Color = "Purple" Or Color = "Yellow" Then
Or you could also use a Case Statement Select Case Color Case "Red" Debug.Print "Do This" Case "Blue" Debug.Print "Do That" Case "Orange", "Purple", "Yellow" Debug.Print "Do the other thing" Case Else Debug.Print "Do the last thing" End Select -- --Roger Carlson MS Access MVP Access Database Samples: www.rogersaccesslibrary.com Want answers to your Access questions in your Email? Free subscription: http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L wrote in message ... Hello. Thanks for the help. I have a form where I am using an if/then code to open a subform. Example: If Color = "Red" Then Do this ElseIf Color ="Blue" Then Do This ElseIf 'Any other...... I want to know if there is a way to make one of my ElseIf selections have more than one option. Something like: If Color = "Red" Then Do this ElseIf Color = "Blue" Then Do This ElseIf Color = "Orange" Or "Purple" Or "Yellow" Do This Thanks Again. |
#3
|
|||
|
|||
VBA Code Help
IF color = "Red" then
' do stuff ELSEIF color = "Orange" OR color = "Purple" OR color = "Yellow" ' do other stuff ELSE ' do default stuff END IF Personally, though I would probably: 1. use a CASE statement or 2. create a lookup table that contains the color and the name of the subform and then perform a lookup to retrieve the name of the form to open based on the color. or 3. use arrays in a similar fashion to #2 or 4. if the user is picking a color use a two column combo box that contains the color in one column and the formname in a second hidden column wrote in message ... Hello. Thanks for the help. I have a form where I am using an if/then code to open a subform. Example: If Color = "Red" Then Do this ElseIf Color ="Blue" Then Do This ElseIf 'Any other...... I want to know if there is a way to make one of my ElseIf selections have more than one option. Something like: If Color = "Red" Then Do this ElseIf Color = "Blue" Then Do This ElseIf Color = "Orange" Or "Purple" Or "Yellow" Do This Thanks Again. |
#4
|
|||
|
|||
VBA Code Help
Thank you both very much. Works like a charm.
|
Thread Tools | |
Display Modes | |
|
|