Results 1 to 4 of 4
  1. #1
    maxyoyo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    2

    Calculation across fields

    Hey there,

    I need a solution for the following problem:
    For example:

    ............F1 F2 F3
    Rec1 ....4 ..2 ..5
    Rec2 ....3 ..3 ..1
    Rec3 ....1 ..2 ..1


    Now, I want to know how many 1s are there in Rec3 the answer is obviously 2 but I want a field(F4, for e.g) that calculates F1+F2+F3 showing all their 1s 2s and 3s.

    A solution I found was...... F4=IIf([F1],1,0)+IIf([F2],1,0)+IIf([F3],1,0)

    But I have over 50 Fields that contain 1s and 2s and I can't count them all by using this formula
    as it will be tremendously long and access will reject it.

    So I need another formula(or function) that will look up for the 1s across multiple fields and show the total count for each record in a new field.



    Tried 'look up' function but achieved nothing~

    Any help/suggestion/advice are highly appreciated.
    Last edited by maxyoyo; 11-15-2014 at 09:37 AM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Access might accept an expression with 50 fields, if the field names are extremely short. I think expression length is limited by number of characters, not number of fields.

    Alternative would be a custom function that opens a recordset and cycles through the fields and increments a variable. Complicated and can be very slow.

    I suspect this data structure is not normalized and that is the real issue.
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I agree that your table structure may be part of the issue.

  4. #4
    maxyoyo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    2
    Thanks for the reply, I will look forward to fixing my table structure.

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

Similar Threads

  1. Problems with calculation fields
    By aboondocksaint2 in forum Queries
    Replies: 1
    Last Post: 04-30-2014, 01:11 AM
  2. Trouble with Calculation Fields
    By DB88 in forum Access
    Replies: 7
    Last Post: 04-22-2014, 08:45 AM
  3. Calculation on two fields
    By braveali in forum Programming
    Replies: 8
    Last Post: 03-01-2012, 01:40 AM
  4. Same calculation on multiple fields
    By tko in forum Queries
    Replies: 4
    Last Post: 05-29-2011, 12:08 PM
  5. Date Calculation within same fields
    By mslieder in forum Queries
    Replies: 3
    Last Post: 01-26-2006, 10:08 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