Results 1 to 2 of 2
  1. #1
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Posts
    52

    Question Question: Can select-case statements be used in an if statement?

    I have two integers that will be examined (A, B). If A = 1, 2, 3... etc then I need to have a set of procedures for B if it's 1, 2, 3... etc.



    I know that I can use a different set of if statements for each variety of A that handles each variety of B. Such as:
    Code:
    Function Rate (A as integer, B as integer) as Integer
    if A = 1 then 
       if B = 1 then
          Rate = 1
       else if B = 2 then
          Rate = 5
       else if ... etc
    else if A = 2
    ...
    end if
    Is it possible to use Select-Case statements instead? Such as:
    Code:
    Function Rate (A as integer, B as integer) as integer
    Select Case A
    Case A is = 1
       Select Case B
       Case B = 1
          Rate = 1
       Case B = 2
          Rate = 5
          End Select    ' End B Case
    ....
    Case A = 2
    ....
    End Select     'End A Case

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    SELECT CASE is very appropriate structure.

    Code:
    Select Case A
        Case 1
            Select Case B
                Case 1
                    Rate = 1
                Case 2
                   Rate = 5
            End Select    ' End B Case
    ....
        Case 2
    ....
    End Select     'End A Case
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Should I /can I use a Select Case statement?
    By Gina Maylone in forum Access
    Replies: 1
    Last Post: 12-13-2014, 12:08 PM
  2. Replies: 4
    Last Post: 10-09-2014, 12:58 PM
  3. Debugging a Select Case Statements
    By dccjr in forum Access
    Replies: 4
    Last Post: 03-05-2013, 04:14 PM
  4. Debugging a Select Case Statements (Still)
    By dccjr in forum Programming
    Replies: 13
    Last Post: 02-28-2013, 09:47 PM
  5. Help with Select Case statement
    By focosi in forum Access
    Replies: 4
    Last Post: 08-09-2011, 12:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums