Use a Microsoft Access Append Query to Create Multiple Records per Row
Question details
Create one output record for each integer from a source row's count down to 1, and optionally append those records to a table.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A PieceTicketLines table contains an mCount value that determines how many records each source row should produce.
- Observed behavior
- An equality join returns only one matching counter per source row. The goal is to produce six records with counter values 6 through 1 when mCount is 6.
Check the largest expected mCount value and create a Counters table with a unique integer field named Counter containing every value from 1 through at least that maximum. Confirm that the source field names match the SQL below, and avoid naming a field Count because it is an SQL reserved word.
Return Multiple Records with a Counters Table
Use a select query when you need the expanded records without storing them in another table.
The query pairs each source row with every counter value up to mCount. An equality join produces only one match, so it does not create the desired sequence.
In Access, use Create > Table Design to create a Counters table with a Number field named Counter. Set Counter as the primary key, save the table, and enter consecutive integers from 1 through the largest expected mCount.
Select Create > Query Design, close the table-selection dialog if it appears, and switch to View > SQL View.
Replace the SQL with: SELECT PieceTicketLines.Project, PieceTicketLines.eMark, Counters.Counter AS SequenceValue, PieceTicketLines.mCount, PieceTicketLines.Series, PieceTicketLines.Width, PieceTicketLines.eLength, PieceTicketLines.GroutCorelnft FROM PieceTicketLines, Counters WHERE Counters.Counter <= PieceTicketLines.mCount ORDER BY PieceTicketLines.Project, PieceTicketLines.eMark, Counters.Counter DESC;
Click Run. For a source row with mCount of 6, the SequenceValue column should show 6, 5, 4, 3, 2, and 1; the original mCount remains 6 in each result row.

Append the Expanded Records to a Destination Table
Use an append query when the generated records must be stored rather than displayed only as query results.
Work with Exported Access Data in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface. Export Access query results to a spreadsheet format to review and share them in WPS; WPS does not run or repair Access append queries.

Frequently Asked Questions
Why does my join return only one copy of each row?
A join condition such as Counters.Counter = PieceTicketLines.mCount matches only the counter equal to mCount. Use both tables in the FROM clause and filter with Counters.Counter <= PieceTicketLines.mCount to return all counters up to that value.
Can I display the values from 6 down to 1?
Select Counters.Counter as a separate output column and add ORDER BY Counters.Counter DESC, along with any source fields you want to group the results by.
Do I have to use an append query?
No. Run the select query in Access to view the expanded records without storing them. Use INSERT INTO only when you need to add them to a destination table.
What happens if the Counters table does not go high enough?
The query can return only the counter values present in the table. Add consecutive integers through at least the largest expected mCount before running the query.
Can WPS Office run the Access append query?
No. Run the query in Microsoft Access. To review its results in WPS Spreadsheets, export the results from Access to an Excel or CSV file and open that file in WPS.




