Results 1 to 4 of 4
  1. #1
    jax1000rr is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    26

    Exclamation Need help with a query using dynamic data

    Hello,



    I need to create a query that will group by a column named defect_no in my table.

    My issue is that this field is dynamic and can have up to 15 different values at any given time; and I need to be able to export a list of records by the corresponding defect_no into individual XLS files based on the defect_no field. Some days there may only be 3 different values for the defect_no column and others there may be all 15.

    Thoughts?

    TIA and please let me know if more clarification is needed.....it's been a long day!

  2. #2
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    If your issue is that you need to export to different spreadsheets based upon the value of the field, then you either create a single query that pulls all the records, SORTED by that field but not grouped by it, and process each record, opening the appropriate XLS whenever the sort field changes...

    or, you create ONE query that GROUPs by the field, store those values in an array, then cycle through the items in the array, and for each, open a SECOND query to get the records for that XLS, process them, then close the XLS and get the next item from the array.

    It's relatively simple VB. I think I posted an example a couple of weeks back, but I don't know what to search for to find it.

    There's an example of loading an array via SQL here https://www.accessforums.net/queries...00/index2.html

    I couldn't find the "writing to an excel spreadsheet" code right off the bat.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @Dal:

    You might check out Ken Snell's site: Ken's ACCESS Examples and Information for Working With EXCEL Workbook Files
    http://www.accessmvp.com/kdsnell/EXCEL_MainPage.htm


    (one of my many 'reference' sites )

  4. #4
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    @ssanfu - Perfect. Good site.

    I actually have working examples of an export to excel at work, but I was just "burning some midnight electrons" at home.

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

Similar Threads

  1. Replies: 13
    Last Post: 09-17-2012, 08:46 PM
  2. VBA Code for Mail Merge via Dynamic Data Exchange
    By Ganymede in forum Programming
    Replies: 2
    Last Post: 12-28-2011, 05:20 PM
  3. Dynamic Form, Dynamic labels/ captions?
    By JFo in forum Programming
    Replies: 15
    Last Post: 10-12-2011, 08:33 PM
  4. Dynamic Data
    By top1hat19 in forum Access
    Replies: 4
    Last Post: 02-14-2011, 06:32 PM
  5. Replies: 1
    Last Post: 07-30-2010, 10:28 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