Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

VBA Code Help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nybaseball22@gmail.com - 01 May 2008 17:53 GMT
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.
Roger Carlson - 01 May 2008 18:19 GMT
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

Signature

--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/wa.exe?SUBED1=ACCESS-L

> Hello.  Thanks for the help.
>
[quoted text clipped - 20 lines]
>
> Thanks Again.
B. Edwards - 01 May 2008 18:21 GMT
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

> Hello.  Thanks for the help.
>
[quoted text clipped - 20 lines]
>
> Thanks Again.
nybaseball22@gmail.com - 01 May 2008 22:17 GMT
Thank you both very much.  Works like a charm.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.