Results 1 to 4 of 4
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    complicated cross tab?

    Hey guys

    Here is an example of a customer's order. The ItmCode field are the protection plans that are associated with that ticket number. There can only be a max of four protection plans per order. I didn't design the current design, I just did some snooping and found out that we have been over paying the protection plan company because of this flawed design. I need to transpose this data somehow so that each order is only 1 record, and the type of protection plans fill in the ItmCode1-4 fields. If there were only 2 plans for an order, ItmCode 3 and 4 would be null.

    Current:


    Click image for larger version. 

Name:	current.PNG 
Views:	8 
Size:	9.3 KB 
ID:	16445

    Desired:
    Click image for larger version. 

Name:	new.PNG 
Views:	8 
Size:	5.2 KB 
ID:	16446

  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
    If the original data had a sequence number for the records of each OrderType group, then the CROSSTAB would be simple. OrderType would be the row header, Sequence would be the column header, and ItmCode would be the value (First() aggregate function).

    How many different protection plans are possible? Here is method for emulating the CROSSTAB: http://www.datapigtechnologies.com/f.../crosstab.html

    Another approach is VBA code writing records to a temp table (temp because the data is purged after each run of the procedure).
    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
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    There are 4 different plans that are available. I was under the impressed that the Value always had to be a number type. Noobie error.

    You slightly lost me with the sequence number bit.

    Our database does use DocLineNum. Here is a snip. The 2 highlighted rows are the protection plans. The farthest column to the left is the line number. The protection plans are not always on the same line, though. I don't have that field readily available in access currently, but I can get it.

    Click image for larger version. 

Name:	gers.PNG 
Views:	8 
Size:	18.9 KB 
ID:	16447

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Oh wow. Just spent 6 hours on this problem only to realize it won't fix the issue with us over paying. No point in fixing this. Sorry June7, thanks for the help anyways.

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

Similar Threads

  1. Complicated loop help
    By xAkademiks in forum Programming
    Replies: 11
    Last Post: 09-01-2012, 09:59 PM
  2. MOST COMPLICATED query ever
    By dastr in forum Queries
    Replies: 1
    Last Post: 07-05-2012, 04:29 AM
  3. Complicated
    By Ganymede in forum Queries
    Replies: 3
    Last Post: 01-22-2012, 06:25 PM
  4. Complicated form
    By secret in forum Access
    Replies: 14
    Last Post: 09-07-2011, 10:16 PM
  5. Complicated IIF?
    By Sweetnuff38 in forum Queries
    Replies: 1
    Last Post: 08-18-2011, 01:13 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