Results 1 to 8 of 8
  1. #1
    Josh330 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2023
    Posts
    12

    Choose Function Limitations

    Hi there. Are there limitations to the Choose function? Such as maximum number of values? For the values, I am using fields. I am asking because I am using the Choose function in many fields in a Query table. It works perfectly, but then for one field it continues to show an #Error message. This happens when I reach 10 values in the list. I have spent hours examining the issue and I cannot figure it out. I think it has something to do with the Choose function. Thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I just tested Choose with 26 elements in VBA and it works.

    There is a limit of 1024 characters in cell of query design grid.

    Post your code.
    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.

  3. #3
    Josh330 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2023
    Posts
    12
    Hi June.

    The below formula works in the Query. The output is a date field. Please excuse the unsophisticated field names.

    Task 010 Start: [Task 010 Gap]+Choose([Task 010 Predecessor],[Task 001 End],[Task 002 End],[Task 003 End],[Task 004 End],[Task 005 End],[Task 006 End],[Task 007 End],[Task 008 End],[Task 009 End])

    The one below results in an #Error. This is pretty much identical to the one above. The added fields I have checked a thousand times.

    Task 011 Start: [Task 011 Gap]+Choose([Task 011 Predecessor],[Task 001 End],[Task 002 End],[Task 003 End],[Task 004 End],[Task 005 End],[Task 006 End],[Task 007 End],[Task 008 End],[Task 009 End],[Task 010 End])

    Thanks.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That looks like a non-normalized data structure.

    See nothing wrong with expression. Now I would have to examine data. If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  5. #5
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    What's the value of Task 011 Predecessor? If it's null or greater than the number of choices you'll get an error, I believe.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    moke, I tested both. If index is Null, does error. If the index is greater than the number of elements, that just returns Null.

    If Null were the issue, wouldn't it error without the 10th element?
    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.

  7. #7
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    @ June7 - This is probably the first time I've looked at the Choose() in 10 or so years so I'm not sure what it would do.
    If it's a date datatype I don't think it can be null. Also not sure what [Task 011 Gap] is as it is being Added (+) to a date. [Task 011 Gap]+Choose([ . . .
    Anything plus null = null.

    This errors

    Code:
    Dim x As Date
    x = Choose(4, #1/1/2021#, #2/2/2022#, #3/3/2023#)
    Debug.Print x
    this does not error. x as variant datatype which can be null

    Code:
    Dim x 
    x = Choose(4, #1/1/2021#, #2/2/2022#, #3/3/2023#)
    Debug.Print x
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Well, the calc seems to be in query so a variable type is not a concern.
    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. Replies: 26
    Last Post: 02-22-2020, 06:15 PM
  2. Replies: 4
    Last Post: 03-31-2017, 08:35 AM
  3. Question appropriate on usage of Choose Function
    By justphilip2003 in forum Access
    Replies: 4
    Last Post: 05-20-2013, 08:41 PM
  4. Long Choose Function
    By Ganymede in forum Access
    Replies: 4
    Last Post: 01-03-2012, 09:41 PM
  5. Access Limitations
    By kketchum in forum Access
    Replies: 2
    Last Post: 08-24-2006, 08:21 PM

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