Results 1 to 2 of 2
  1. #1
    therzakid is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    22

    advanced product attachment query

    Hello,

    I'm trying to evaluate the ability of sales in attaching products to orders e.g. if the order (OrderNo) has a computer purchased, i'd like to see if they were able to attach an accessory product like Software, ESP (extended service plan), or whatever else I may want to see. I've identified the computers vs accessories by using Category (can be either VAIO or Accy). Also, I have SubCat as a subcategory that will classify the computers as a particular model. The end game is to have a query (crosstab?) that depicts the one below.

    http://i1198.photobucket.com/albums/...id/dataimg.png

    Also, June7 gave me some code for something similar and did what I asked but I was unable to adapt it to this project.

    Thanks a ton and I've attached the db to see what I have done and for your testing purposes.



    Kind regards,
    Craig

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Your image shows source and ouput for televisions and accessories. The output summarizes by TV size. The table in file is computers and accessories. You should show example output for this. But I might have something anyway.

    Expressions for the SELECT query.
    ItemCount: DCount("OrderNo","Table1","OrderNo='" & [OrderNo] & "'")
    MainItem: DLookUp("SubCat","Table1","Category='VAIO' AND OrderNo='" & [OrderNo] & "'")
    SubCategory: IIf([Category]="Accy",[Subcat],"PC")

    Crosstab query:
    TRANSFORM Count(Query1.Units) AS CountOfUnits
    SELECT Query1.MainItem
    FROM Query1
    WHERE ((Not (Query1.MainItem) Is Null) AND ((Query1.ItemCount)>"1"))
    GROUP BY Query1.MainItem
    PIVOT Query1.SubCategory;

    Be aware, this crosstab is slow.

    Did a spot check of totals. Filtering the SELECT shows there should be 212 ESP items but the crosstab shows 211. Order 0101028DMTH has two accessory items but no computer. So this is good, it is working.
    Last edited by June7; 07-30-2011 at 06:19 PM.
    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. Advanced CountIf Query
    By therzakid in forum Queries
    Replies: 2
    Last Post: 07-27-2011, 10:45 PM
  2. Replies: 1
    Last Post: 03-09-2011, 08:54 AM
  3. Advanced Query
    By Cined in forum Queries
    Replies: 1
    Last Post: 03-04-2011, 03:40 PM
  4. Advanced Query
    By Exwarrior187 in forum Queries
    Replies: 6
    Last Post: 01-14-2011, 10:11 AM
  5. Product in a Summary Query
    By Fletch in forum Queries
    Replies: 0
    Last Post: 12-11-2008, 03:14 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