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 / Modules / DAO / VBA / August 2006

Tip: Looking for answers? Try searching our database.

Select Case Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kirk P. - 11 Aug 2006 15:46 GMT
This Select Case statement isn't returing the desired results.  I'm trying
for, in case 1, when the expression evaluates to True, return "Direct Ops
Expense".  What am I doing wrong?

Function RowDesig2(AcctLvl1 As String, FuncGroup As String, Prod As String)

Select Case RowDesig2
   Case [AcctLvl1] <> "Revenue" And [FuncGroup] = "Operations" And [Prod]
<> "999"
       RowDesig2 = "DIRECT OPS EXPENSE"
   Case [AcctLvl1] <> "Revenue" And [FuncGroup] = "Products" And [Prod] =
"999"
       RowDesig2 = "INDIRECT OPS EXPENSE"
   Case [AcctLvl1] <> "Revenue" And [FuncGroup] <> "Operations" And
[FuncGroup] <> "Products"
       RowDesig2 = "OTHER SGA - SHARED SERVICES"
   Case Else
       RowDesig2 = "SOME OTHER DESIGNATION"
   End Select
   
End Function
John Spencer - 11 Aug 2006 15:57 GMT
Generally case can only evaluate ONE variable.
How about rewriting the function as follows?

Function RowDesig2(AcctLvl1 As String, FuncGroup As String, Prod As String)

IF  AcctLvl1 <> "Revenue" And _
   FuncGroup = "Operations" And Prod <> "999" THEN
       RowDesig2 = "DIRECT OPS EXPENSE"

ELSEIF AcctLvl1 <> "Revenue" And  _
  FuncGroup = "Products" And Prod = "999" THEN
       RowDesig2 = "INDIRECT OPS EXPENSE"

ELSEIF AcctLvl1 <> "Revenue" And _
  FuncGroup <> "Operations" And  FuncGroup <> "Products" THEN
       RowDesig2 = "OTHER SGA - SHARED SERVICES"

ELSE
       RowDesig2 = "SOME OTHER DESIGNATION"
END IF

End Function

> This Select Case statement isn't returing the desired results.  I'm trying
> for, in case 1, when the expression evaluates to True, return "Direct Ops
[quoted text clipped - 18 lines]
>
> End Function
Kirk P. - 11 Aug 2006 16:11 GMT
I did have the function using the IF statement almost exactly as you
described.  I guess I was under the impression that when using an IF
statement with multiple cases, then the SELECT CASE statement is optimal.  I
don't have as much experience with the SELECT CASE, so I was just giving it a
try.

Thanks for the feedback!  I'll just use the IF.

> Generally case can only evaluate ONE variable.
> How about rewriting the function as follows?
[quoted text clipped - 41 lines]
> >
> > End Function
 
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.