Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Sep 2003
    Location
    Houston, Texas, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nested if function (Access 2003)

    I have a user who wants to run a nested if function with 110 if... elseif. When he reaches 55 the code stops and drops him out. I have looked at the code and debugged it to the point that I know it consistently drops out at 55. I can find no statistics on how many nestings one can have in Access. The problem is changing the code to a select case will not work because he really needs to test 110 conditions.

    Any help???

    Thank you,

    deutsch

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Nested if function (Access 2003)

    Why would he need to test that many conditions? It sounds like the data structures are poorly designed or this situation would not arise. Can you give an example of the sort of tests you're talking about? Also, are you talking about nested conditions or multipe else-if conditions. They aren't the same thing. Nested Ifs are If-End If statements nested within another If-End If structure.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Sep 2003
    Location
    Houston, Texas, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Nested if function (Access 2003)

    He is trying to create a flat file from a well designed system. The flat file will be merged in Word and send via e-mail to clients.

  4. #4
    Star Lounger
    Join Date
    Sep 2003
    Location
    Houston, Texas, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Nested if function (Access 2003)

    To the second half of your question:
    if isnull(a) then
    do one
    elseif isnull(([img]/forums/images/smilies/cool.gif[/img] then
    do two
    etc
    etc
    end if

    Does that explain it?
    This works like a charm until we reach the 55th condition.

    Thanks,

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Nested if function (Access 2003)

    It's still not clear to me why you would need over 100 conditions, but does this work?

    Select Case True
    Case IsNull(a)
    DoOne
    Case IsNull([img]/forums/images/smilies/cool.gif[/img]
    DoTwo
    ...
    End Select

  6. #6
    Star Lounger
    Join Date
    Sep 2003
    Location
    Houston, Texas, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Nested if function (Access 2003)

    Thank you Hans. I will try that and see if it works. I had considered select case and could not see how it would work here. Your example makes sense and I will try it. The reason that my user needs more 100 if statements is that he has potentially 110 records that need to be combined into one flat record into up to 110 fields. As he loops through the first record set if speciifc conditions are met the value from that record is placed into the next available field in the target table. This works great until record number 55 - then nothing! Is there a limit to the number of nested ifs and/or if endifs?

    Thanks for your help. I will try the select case - since this has now been dumped onto me!

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Nested if function (Access 2003)

    I am not aware of a limit to the ElseIf construction, but then, I never tried it with more than a few ElseIfs...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •