Answered Maximum number of nested cases in a select case ?

  • Monday, September 17, 2012 7:00 PM
     
     

    Hi all,

    Is there a maximum number of cases nested in a select case ?

    Thanks

    João

All Replies

  • Monday, September 17, 2012 8:00 PM
     
     
    On Mon, 17 Sep 2012 19:00:52 +0000, João Simplicio Rodrigues wrote:
     
    >
    >
    >Hi all,
    >
    >Is there a maximum number of cases nested in a select case ?
    >
    >Thanks
    >
    >João
    >
     
    I've never seen that documented anyplace.  Are you having a problem?  What version of VBA?
     

    Ron
  • Wednesday, September 19, 2012 5:57 PM
     
     

    Hi Ron

    well as was using about 160 case just by repeating two conditions interpreted as not working ...

    Already corrected. Up to 160 can guarantee that it works. ;)

    Regards.

    João.

  • Friday, September 21, 2012 11:14 AM
     
     Answered

    If 160+ cases are needed, I suspect that these values for the cases should be handled as Field values in Table(s) and not in code. 

    VBA code / Select Case ... statement cannot replace data stored in Table(s).  Besides with 160 cases, it is certainly more efficient for the ACE/JET database engine to handle and not VBA processing.


    Van Dinh

  • Friday, September 21, 2012 11:24 AM
     
     

    Ah, I thought you were "nesting". But it seems like you just have multiple included Case statements.

    I don't know of any limit as to how many Case statements can be included in a Select Case ... construct.  I suspect it has more to do with limits on VBA project size.

    However, as Van Dinh has pointed out, it might be more efficient to construct some kind of lookup table, or array, to access these alternatives.


    Ron