INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Printing duplicates records based on number value entered into field

Printing duplicates records based on number value entered into field

Printing duplicates records based on number value entered into field

(OP)
Hi,
I have a Main form (Jobs) and subform (Delivery Docket) 1:M that runs the following code behind a print button. The code essentially takes the line record or all line records from the subform (Delivery Dockets Table) and appends this to a temp table called DeliveryDocketTemp Table. Now depending on the the number entered in field name "LabelCount" it will duplicate the line record or lines of records based on this value. Codes works fine if you only run this code for 1 line of record on the subform. But if I try to run the code to append all subsequent lines on the subform the number of records appended in the temp table don't add up, except when the number entered in the "LabelCount" field are even numbers. Example, if I enter 1 in "LabelCount" field of the first line and 2 in "LabelCount" field of the 2nd line it appends line record of line 1 three times and line 2 three times in the temp table. But if I enter 2 in "LabelCount" fields of both lines no problem at all it will append both lines of records twice. Seems to only work if the number entered in the "LabelCount" fields in all lines are entered same.

DoCmd.SetWarnings False
DoCmd.OpenQuery "DeleteDeliveryTemp", acNormal, acEdit
For I = 1 To Forms!Jobs![Delivery Dockets].Form!LabelCount
DoCmd.OpenQuery "AppendDeliveryTemp", acNormal, acEdit
Next
DoCmd.SetWarnings True
stDocName = "Labels"
DoCmd.OpenForm stDocName

Perhaps, there is another way to write this code so that it duplicates or appends the line of records based on the numerical value entered in the "LabelCount" field. Any assistance would be greatly appreciated.

RE: Printing duplicates records based on number value entered into field

Do you really need duplicate records or only multiple copies of the same record? I used a table of numbers [tblNums] with a numeric field [Num]. Add numbers 1 through the maximum number you will ever need. Add this table to your report's records source query with no join lines. Then set the criteria under the [Num] field to

<=[LabelCount]

This will produce multiple copies of each record.

Duane
Hook'D on Access
MS Access MVP

RE: Printing duplicates records based on number value entered into field

(OP)
Hi Duane,

Worked like a charm...appreciate your reply
Thanks very much.....

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close