473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

repeating a record x times in a query

Hi, I have a somewhat unique problem (at least unique to me, and I've
been doing this for longer than I care to admit). I have a client that
needs to print cards onto perforated card stock (so multiple records
per page), and they need to print out x copies of the same information
onto the cards. So for instance I have a record that has a name,
address, id number and then a number for the number of copies of that
record that needs to be printed out.

I know I can do this programmatically with the report to print out x
number of copies per record, but this would waste several hundred pages
of card stock by printing out blank cards. It also just doesn't seem
like the cleanest most elegant way of accomplishing this.

Has anyone ever accomplished this? Transforming a query of
"Name", "Address", 3
"Name2", "Address2", 2

to:

"Name", "Address"
"Name", "Address"
"Name", "Address"
"Name2", "Address2"
"Name2", "Address2"

Anyone have any ideas?
Any and all help would be appreciated.

-Charles

Nov 13 '05 #1
3 6356
Okay, in (partial) answer to my own, I can create a new table with the
desires results with the following function:

Function make_rst()

Dim db As Database
Dim rst, rst_new As Recordset
Dim i As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM copy_test")
Set rst_new = db.OpenRecordset("destination")
While Not rst.EOF
For i = 0 To rst.copies
rst_new.AddNew
rst_new!Address = rst!Address
rst_new.Update
Next
rst.MoveNext
Wend

End Function

which sort of solves the problem, except that I really dislike "temp"
tables, and moving data around like this. Is there another solution
I'm overlooking?

Nov 13 '05 #2
"Chuck" <us****@popquizhotshot.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi, I have a somewhat unique problem (at least unique to me, and I've
been doing this for longer than I care to admit). I have a client that
needs to print cards onto perforated card stock (so multiple records
per page), and they need to print out x copies of the same information
onto the cards. So for instance I have a record that has a name,
address, id number and then a number for the number of copies of that
record that needs to be printed out.

I know I can do this programmatically with the report to print out x
number of copies per record, but this would waste several hundred pages
of card stock by printing out blank cards. It also just doesn't seem
like the cleanest most elegant way of accomplishing this.

Has anyone ever accomplished this? Transforming a query of
"Name", "Address", 3
"Name2", "Address2", 2

to:

"Name", "Address"
"Name", "Address"
"Name", "Address"
"Name2", "Address2"
"Name2", "Address2"

Anyone have any ideas?
Any and all help would be appreciated.

-Charles

If the number of duplicates which are needed are not too large (and can be
guaranteed to be within a certain range) then you could achieve this using
no code at all with the help of another table:
tblCopy
Qty F1
1 1
2 1
2 2
3 1
3 2
3 3
4 1
4 2
4 3
4 4
etc

Then your query joins tblAddress.Qty to tblCopy.Qty so you get the correct
number of records.

Another way is to write some VBA within the report which forces the section
to be repeated until the correct number of copies is reached. This may be a
better solution, but the first has advantages too since you can use it for
the underlying query, whereas the second only works for reports.


Nov 13 '05 #3
From my files ----

Use the same methodology fir your cards!

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

Print Multiple Labels Based Upon The Amount In A Column

Q I have a query that shows information about individual product items and
includes a column for quantity on hand for each item. Each item has a
different quantity on hand. for example:
ProductName QOH
item1 3
item2 2
item3 4
I would like to print labels, one for each of the items. In the above
scenario, I would need 9 labels and would like the labels for each item to
print consecutively. How do I design a query to read the "quantity on hand"
column and generate the appropriate number of records for each specific
item? For example, item1 has 3 in stock, the query would show:
item1
item1
item1
A Create a table (tblNums) with a single, numeric field (Num) and add
numbers(records) from 1 to your maximum QOH. Add this table to the report's
record source query with no join between the tables. This is called a
cartesian query. Set the criteria under the Num field to:
<=[QOH]
You will get 3 records for Item1, 2 records for Item2 and 4 records for
Item3.

"Chuck" <us****@popquizhotshot.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi, I have a somewhat unique problem (at least unique to me, and I've
been doing this for longer than I care to admit). I have a client that
needs to print cards onto perforated card stock (so multiple records
per page), and they need to print out x copies of the same information
onto the cards. So for instance I have a record that has a name,
address, id number and then a number for the number of copies of that
record that needs to be printed out.

I know I can do this programmatically with the report to print out x
number of copies per record, but this would waste several hundred pages
of card stock by printing out blank cards. It also just doesn't seem
like the cleanest most elegant way of accomplishing this.

Has anyone ever accomplished this? Transforming a query of
"Name", "Address", 3
"Name2", "Address2", 2

to:

"Name", "Address"
"Name", "Address"
"Name", "Address"
"Name2", "Address2"
"Name2", "Address2"

Anyone have any ideas?
Any and all help would be appreciated.

-Charles

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dean | last post by:
I am a developer who works with MS SQL Server a lot, but I'm far from an expert. I am revamping an appointment scheduling system that allows for appointments to reoccur daily, weekly, monthly and...
2
by: tom | last post by:
Hi, I have built an Access DB for a child care business. Family table stores the Family info. Room the different room names, capacity etc. Price stores the various price codes and amounts. The...
10
by: Mark | last post by:
I have a table about people containing 25 fields. The table contains the usual fields - first, last, address, city, state and zip. There is no primary key. These fields all have data with the...
2
by: Alpha | last post by:
I have a C# program that user would select several search criteria and then outputs to the Crystal Report. A message is output to user if no matching record is found. In my code I also clear,...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
4
by: Noah | last post by:
Hi, I bet the question below has been answered many times before, but I have not found an answer. If someone could point me to one that would be great! I have the following table: num ...
0
by: Killer42 | last post by:
This is a simple VB6 function to generate random numbers in the specified range, without repeating any numbers. New, and only briefly tested. Use at your own risk. :) Option Explicit Private...
3
by: dufnobles via AccessMonster.com | last post by:
I have created a query which returns a single record. I then display the four fields returned by the record on my form. I would like to display the same record three times with only the record...
5
by: squrel | last post by:
Hello everyone.. i have a small problem here... i have a combobox in my project call cmbresult which has been filled up in the properties by using list properties... i have 4 option there... whn i...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.