Copy one record to more records. reverse of grouping

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • provokatori
    New Member
    • Nov 2013
    • 4

    #1

    Copy one record to more records. reverse of grouping

    Gents I really do not have an Idea how I could do this thing. Have an excel sheet which I receive from my customer and I get imported to Access and I would call that table tblCustomer and that would look something like this:

    ProductID | Name | Expire date | SumofQty
    3 | Flour | 13-Dec-2013 | 6
    6 | Meat | 20-Jan-2014 | 10
    So the table contain maybe 100 items. I want in the same table or another table to copy the same record 6 times as per SumofQty and than the next record copy it 10 times and so on. I need this cause I will create labels for each product right now I`m doing manually :((( Please if someone has an Idea how to do it :(
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    So, just to be clear,
    from your example data table
    you need:
    6 lables that have PrdID3, Flour: Exp13-Dec-2013,
    10 lables for the meat
    and so forth.

    You are receiving this information via an excel workbook.

    Is this correct?
    [edit]
    If so, then you really don't need VBA to do this.
    Create a table with a single field, set as primary, type cast as Number(long)
    Enter a number of records... say 1 thru 20
    call this "tbl_repeat er" name the field [repeater_pk]

    Now in a QUERY!!!
    show the imported table, show the repeater table,
    add the fields you want shown from the import
    add the repeater field;however, uncheck show
    what we will do is take the cartesian product between this repeater table and your imported table and limit the records returned against [tbl_repeater]![repeater_pk] by returning only those [tbl_repeater]![repeater_pk]<=[tbl_import]![SumOfQty]

    Save this query,
    use it to feed your report.

    -z
    Last edited by zmbd; Dec 11 '13, 08:59 PM.

    Comment

    • provokatori
      New Member
      • Nov 2013
      • 4

      #3
      Ok that is what I ask and I got it. worked like a charm. but can I have an autonumber for each repeater like for each record have another column and have:

      ProductID | Name | Expire date | SumofQty |Autonumber
      3 | Flour | 13-Dec-2013 | 6 | 1
      3 | Flour | 13-Dec-2013 | 6 | 2
      3 | Flour | 13-Dec-2013 | 6 | 3
      6 | Meat | 20-Jan-2014 | 10 | 1
      6 | Meat | 20-Jan-2014 | 10 | 2
      6 | Meat | 20-Jan-2014 | 10 | 3 and so one

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Yes, where I had you uncheck show, check mark it instead. Run the query, you should now see the [repeater_pk] so long as this is sequential in nature, you should get the numbering as desired.

        Comment

        Working...