I created a report with the Access Wizard to print Avery 5160 labels (( 1″ X 2 5/8) 3 Columns 10 Rows), set to print across then down.
How can I have the report start printing at a specific row and column using VBA?
Thanks in advance
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Label Printing (A2k SP1)
Put these code in a module.
The two Dim lines must be in the beginning of the module, before any other Function or Sub
Dim intLabelBlanks As Integer Dim intBlankcount As Integer Function LabelLayout(R As Report) If intBlankcount < intLabelBlanks Then R.NextRecord = False R.PrintSection = False intBlankcount = intBlankcount + 1 End If End Function Function LabelInitialize() intBlankcount = 0 End Function Function LabelSetup() intLabelBlanks = Val(InputBox$("Enter Number of blank labels to skip")) If intLabelBlanks < 0 Then intLabelBlanks = 0 End Function
In the design of the report, select the event property tab of the Report.
For the on Open event enter : =LabelSetup()
For the on Activate event enter : =LabelInitialize()
Select the event property tab of the Detail
for the on Print event enter : =LabelLayout([Reports]![ReportName])
Replace ReportName with the name of your report.
This code is a simplified version of the code of the Reports Sample Database from Microsoft available at :
Microsoft Access 2000 Sample Reports Available in Download Center (Q231851)
I know you already got a satisfactory solution, but I had a similar situation which I handled quite differently. On a Labels form, which allowed the user to select Mailing Labels, File Folder Labels, Shipping Labels, etc. I added a textbox for Starting Row (named StartRow) of the sheet of labels. My support personnel are very conscientious about saving EVERY PENNY so they asked for this. The default, of course, is 1. If they have a sheet with 2 rows of labels already removed they simply change the testbox to the value (number) “3”. In each saved report (1 for each type of label) I put the following code in the OnOpen property:
Me.ReportHeader.Height = (1440 * Forms!PrintLabels!StartRow) – 1440
There are no fields in any of the report headers. 1440 is the conversion between twips (whatever they are!) and inches.
It works perfectly. As all of us loungers have repeatedly discovered, this program always gives us more than one way to skin a cat!!!
Just food for thought
Kathi
The link in post 124,503 does not work anymore.
The Reports Sample Database can be now be found at :
Download details: Access 2000 Sample: Report Topics
I was just wondering if you had encountered a problem with the labels. I have one setup with 5160 also but occassionally, when i open the labels, it changes it layout to print out the labels all in the first left hand column only. All the records are there, but the template seems to have changed. Of course, then sometimes it opens like it should. I’ve tried creating a new one but still encounter the problem. Not sure.
-Youa
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications