Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Having Problem with Select Case

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
haroldj@shfoodbank.org - 26 Jul 2006 20:03 GMT
Hi -- This is my situation: I have a list box from which users can
choose the report that they want to print.  The code works just fine
when I use an "If-Then-Else" construct but not so when it is
transferred to "Select Case".  Here is a snippet from both:

If lstStores.ListIndex = 0 Then
              stFullName = "I:\Ops\Grocery Rescue\Jet
Reports\Rosauers\Rosa01\Rosa01.xls"
         ElseIf lstStores.ListIndex = 1 Then
              stFullName = "I:\Ops\Grocery Rescue\Jet
Reports\Rosauers\Rosa02\Rosa02.xls"
         ElseIf lstStores.ListIndex = 2 Then
              stFullName = "I:\Ops\Grocery Rescue\Jet
Reports\Rosauers\Rosa03\Rosa03.xls"
etc.

Select Case stFullName
        lstStores.ListIndex = 0: stFullName = "I:\Ops\Grocery
Rescue\Jet Reports\Rosauers\Rosa01\Rosa01.xls"
        lstStores.ListIndex = 1: stFullName = "I:\Ops\Grocery
Rescue\Jet Reports\Rosauers\Rosa02\Rosa02.xls"
etc..

Also, I've tried this with the Value property as well as the ListIndex
property of the ListBox object and the results are the same.
Bob Phillips - 26 Jul 2006 22:04 GMT
The syntax should be

Select Case lstStores.ListIndex
   Case 0: stFullName = "I:\Ops\Grocery Rescue\Jet
Reports\Rosauers\Rosa01\Rosa01.xls"
   Case 1: stFullName = "I:\Ops\Grocery Rescue\Jet
Reports\Rosauers\Rosa02\Rosa02.xls"
etc..
   End Select

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> Hi -- This is my situation: I have a list box from which users can
> choose the report that they want to print.  The code works just fine
[quoted text clipped - 21 lines]
> Also, I've tried this with the Value property as well as the ListIndex
> property of the ListBox object and the results are the same.
haroldj@shfoodbank.org - 26 Jul 2006 23:11 GMT
Bob -- Thanks a bunch!  Worked like a charm.

Harold

> The syntax should be
>
[quoted text clipped - 38 lines]
> > Also, I've tried this with the Value property as well as the ListIndex
> > property of the ListBox object and the results are the same.
 
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.