Results 1 to 3 of 3
  1. #1
    gallegod is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Toronto
    Posts
    1

    Creating data from a "Count" field

    Hi!


    Dominic here and I'm new to the community. I took Microsoft Access in school this year and I really love its functions and I though it could help me make my work easier but im not sure how to approach it..

    I need to create mailing labels from an excel sheet that I can import into Access. Here is a sample of the table where in real life, I would have 20+ different "names" and the "count" range would be in the 5-50.

    Step 1
    Name Code Count
    ADAM BB 3


    MARK CC 2
    JOHN DD 4

    I was hoping that access has a feature to turn this data into what is shown below

    Step 2
    ADAM BB
    ADAM BB
    ADAM BB
    MARK CC
    MARK CC
    JOHN DD
    JOHN DD
    JOHN DD
    JOHN DD

    Then I would make these into labels and print them.. I need your help to figure out how to go from step 1 to step 2..

    Any idea?

    Thanks!

    Strugling student,


    Dominic

  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,632
    I expect any solution will require VBA code.

    It is possible to have records print repeatedly in a report by code in Detail section Format event and in my experience is very, very tricky.

    Otherwise, code could write duplicate records to a 'temp' table which is purged after each process.
    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
    mrojas is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    June7 is correct, a solution to your challenge would require VBA code.
    This solution would probably require two loops, in inside the other.

    I would start by creating a query to select records from step 1.

    Create a temporary table to hold the records from step 2 above.

    Delete any records from the temporary table

    Create a recordset using the query as its data source

    Start a loop with the recordset
    Check the count field
    Loop as many times as the count field indicates, adding records to the temporary table
    Exit loop when you have added the indicated number of records
    On the outer loop, move to the next record in the recordset until end of file

    Using the temporary table, do with it as needed.

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

Similar Threads

  1. Creating a "search" field in the header
    By MissLotus in forum Forms
    Replies: 9
    Last Post: 07-24-2013, 03:52 AM
  2. Replies: 7
    Last Post: 05-12-2013, 05:15 AM
  3. Replies: 3
    Last Post: 04-22-2013, 06:08 AM
  4. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 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