Results 1 to 4 of 4
  1. #1
    whitelockben is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    5

    Complex Tables to Sum

    Hi all,

    I have a form which is allowing input of equipmet info. To keep is simple I have tried to dumb it down as much as possible. Here is an example of the table with some data in.



    Now my aim is to be able to have a table which creates a unique record for every combination of location and seg. type.

    For example from this table the new table would create a new record for ZE-A ZE-B etc etc. There will always be the same number of segrigation types however there will be an undetermined number of locations.

    The aim of having these new records is to have a field in each record which sums the total weight of the equipment at each location based on the segrigation type and another for the size.

    An example of what I am looking for is:





    Is this possible does anyone know

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Certainly anything is possible. Just might require some very elaborate VBA coding.

    What criteria would determine which equipment are summed for each SegType and Location combination?
    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
    whitelockben is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    5
    It could be anything.

    The knowns are the weight for each piece of equipment.

    However there could be any combinations of seg type and equipment, more of less.

    I am thinking of doing this another way and writing to a second table relating to the selection seg type, however I dont know how I would get one record for each location and keep adding the weights and sizes no new fields?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Using the sample data, these two queries will accomplish creating the combined SegType and Location codes.

    SELECT Equipment, SegType, Weight, Size, [SegType] & "-" & Left([Location],1) AS L1, [SegType] & "-" & Mid([Location],2,1) AS L2, [SegType] & "-" & Mid([Location],3,1) AS L3, [SegType] & "-" & Mid([Location],4,1) AS L4
    FROM Table1;

    SELECT *
    FROM (SELECT Equipment, Weight, Size, L1 As Code FROM Query1
    UNION SELECT Equipment, Weight, Size, L2 As Code FROM Query1
    UNION SELECT Equipment, Weight, Size, L3 As Code FROM Query1
    UNION SELECT Equipment, Weight, Size, L4 As Code FROM Query1) AS Q
    WHERE Mid(Code,4,1)<>"";

    Matching the codes with the correct weight and size calcs requires reliable criteria. Is code ZE-A always EQUIP1 + EQUIP5? If there is no consistent pattern, I don't see this can be done.
    Last edited by June7; 10-11-2011 at 10:12 AM.
    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. Help with complex 'IF' function(s) ...
    By Captain Database ...!! in forum Queries
    Replies: 4
    Last Post: 06-13-2011, 12:40 PM
  2. Complex Criteria
    By Kapelluschsa in forum Queries
    Replies: 7
    Last Post: 05-23-2011, 03:45 PM
  3. Help with complex query (for me at least)
    By GrindEspresso in forum Queries
    Replies: 5
    Last Post: 01-26-2011, 11:03 AM
  4. Complex Form Question - 2 Tables, Different Fields
    By nichojo in forum Programming
    Replies: 6
    Last Post: 08-03-2010, 07:12 AM
  5. need help, expression is too complex?
    By ice673 in forum Queries
    Replies: 5
    Last Post: 02-15-2010, 09:03 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