473,587 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing individual mailing label question

Hi all

I have a student database where I would like to be able to print just
one mailing label, for the student whose record I am currently
accessing on the form. I want to be able to click on the command
button and have the label print out on my labelwriter.

I have done some searching on the web, and found how to print single
labels using a parameter query, but how do I set it up to print the
current record on the form?

Thanks for any help you can provide.

Dave
Sep 7 '06 #1
7 2008
you pass the record ID when you open the report. See DoCmd.OpenRepor t.
One of the arguments is a filter (pass a valid where clause). I think
there's even a wizard for creating a button to do this.

Sep 7 '06 #2

Dave wrote:
Hi all

I have a student database where I would like to be able to print just
one mailing label, for the student whose record I am currently
accessing on the form. I want to be able to click on the command
button and have the label print out on my labelwriter.

I have done some searching on the web, and found how to print single
labels using a parameter query, but how do I set it up to print the
current record on the form?

Thanks for any help you can provide.

Dave
Okay, now I'm at home where I can actually look at a database and not
screw things up. Here's an example using Northwind.

I put a button on the "Customer Orders" form. On that form is a
control called "CompanyNam e", which is a text field. Here's the code
that opens the Customer Labels report with a label for only the current
company (on the Orders form).

Option Compare Database
Option Explicit

Private Sub cmdPreviewLabel s_Click()
On Error GoTo Err_cmdPreviewL abels_Click

Dim stDocName As String

stDocName = "Customer Labels"
'---this is the line that opens the report...
'---the filter points at the CompanyName field on the open form...
'---the single quotes are to delimit the text value.
DoCmd.OpenRepor t stDocName, acViewPreview, , "[CompanyName]='" &
Me.CompanyName & "'"

Exit_cmdPreview Labels_Click:
Exit Sub

Err_cmdPreviewL abels_Click:
MsgBox Err.Description
Resume Exit_cmdPreview Labels_Click

End Sub

Does that work for you?

Sep 8 '06 #3
On 7 Sep 2006 19:44:00 -0700, pi********@hotm ail.com wrote:
>Okay, now I'm at home where I can actually look at a database and not
screw things up. Here's an example using Northwind.

I put a button on the "Customer Orders" form. On that form is a
control called "CompanyNam e", which is a text field. Here's the code
that opens the Customer Labels report with a label for only the current
company (on the Orders form).

Option Compare Database
Option Explicit

Private Sub cmdPreviewLabel s_Click()
On Error GoTo Err_cmdPreviewL abels_Click

Dim stDocName As String

stDocName = "Customer Labels"
'---this is the line that opens the report...
'---the filter points at the CompanyName field on the open form...
'---the single quotes are to delimit the text value.
DoCmd.OpenRepor t stDocName, acViewPreview, , "[CompanyName]='" &
Me.CompanyNa me & "'"

Exit_cmdPrevie wLabels_Click:
Exit Sub

Err_cmdPreview Labels_Click:
MsgBox Err.Description
Resume Exit_cmdPreview Labels_Click

End Sub

Does that work for you?
I think that makes sense. So does this mean I should base the label
report on the table the form is based on rather than the parameter
query?

The table and form are called "Students" and the report for producing
the labels is called "Student Mailing Labels."

The code for mine looks a lot more complicated, and I'm thinking
that's because it's based on a parameter query.

Thank you very much.

Dave
Sep 8 '06 #4
No, you don't need the parameters in there. As a matter of fact, you
don't need any filters at all. You can pass _all_ those in the Open
event of your report. So you can build them on the fly. Have a look
at the Customer Labels form in Northwind. Basically all the form does
is collect parameters and then pass them to the report. The report
itself doesn't have any.

Sep 8 '06 #5
On 7 Sep 2006 19:44:00 -0700, pi********@hotm ail.com wrote:

After looking at my database, changing the report to remove the
parameter query, and trying to include the code you gave me, I do have
a couple of questions.
>Okay, now I'm at home where I can actually look at a database and not
screw things up. Here's an example using Northwind.

I put a button on the "Customer Orders" form. On that form is a
control called "CompanyNam e", which is a text field. Here's the code
that opens the Customer Labels report with a label for only the current
company (on the Orders form).
>Option Compare Database
Option Explicit
I have multiple buttons on my form (Find, First Record, Previous
Record, Next Record, Last Record, Duplicate Record), so it has code
for all of these. Does the "Option Explicit" go at the very top of
all this, right after "Option Compare," or does it go in the section
pertaining to the specific "print label" button I'm creating?
>Private Sub cmdPreviewLabel s_Click()
On Error GoTo Err_cmdPreviewL abels_Click

Dim stDocName As String

stDocName = "Customer Labels"
'---this is the line that opens the report...
'---the filter points at the CompanyName field on the open form...
'---the single quotes are to delimit the text value.
DoCmd.OpenRepor t stDocName, acViewPreview, , "[CompanyName]='" &
Me.CompanyNa me & "'"
My mailing labels will be individual students, so they'll have first
name (Control: First Name) and last name (Control: Last Name), not a
company name. Can I put [Last Name] in there instead? The only
reason I ask is that "Last Name" doesn't seem to fit where your
"Me.CompanyName " is. Should it be Last_Name? Or should it be
included with the brackets?

Please bear with me. Most of the stuff I've learned about Access has
been self-taught from a book, so I'm sure I've got some holes in my
knowledge, especially where programming it is concerned.
>Exit_cmdPrevie wLabels_Click:
Exit Sub

Err_cmdPreview Labels_Click:
MsgBox Err.Description
Resume Exit_cmdPreview Labels_Click

End Sub

Does that work for you?
It looks like the only two "new" pieces of code are the "Option
Explicit" and the "DoCmd" line. Everything else that you posted seems
to be already there just from creating the button. So those two new
additions are what makes Access print just the one label?

Thank you again.

Dave
Sep 8 '06 #6
No, this is what causes the report to only contain one label:

DoCmd.OpenRepor t stDocName, acViewPreview, , "[CompanyName]='" &
Me.CompanyName & "'"

Sep 8 '06 #7
On 8 Sep 2006 12:31:13 -0700, pi********@hotm ail.com wrote:
>No, this is what causes the report to only contain one label:

DoCmd.OpenRepo rt stDocName, acViewPreview, , "[CompanyName]='" &
Me.CompanyNa me & "'"
I think I got it to work. Now to figure out why it's wanting to print
two "pages" (labels) rather than just the one, but I'm sure that's
just a label formatting problem.

Thank you for your help.

Dave
Sep 8 '06 #8

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

Similar topics

3
4309
by: Grim Reaper | last post by:
I print mailing labels out of Access 2000 databases about 3 to 4 times a week. I have been having problems with one thing since I have been printing mailing labels. I print mailing labels by using a report I created and then printing them on a continuous-feed dot matrix printer. I used the Label Wizard, chose the query I created, picked the 'Avery USA 4146' (1 7/16" x 4") - 3 across, paper size: 'Fanfold 358mm x 12 in', and Printer:...
2
1412
by: woodensails | last post by:
I have a table with multi objects among which are surname and spouse. This is part of a membership list, I would like to print membership cards for member and spouse. No problem doing separate runs, but would like to print all in one run. Suggestions please Lyn
0
1124
by: Gregg | last post by:
Hi All, I have an app that I have written that reads a text file into a SQL database, and then uses that database to generate a variety of mailing labels. All of my laser label formats work just fine, however I am having problems with my dot matrix format. I display a print preview of the labels before printing in a CrystalReportViewer. Then I call PrintOptions to generate the labels. I have done alot of looking around for answers to...
2
13496
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to execute a MailMerge to create mailing labels or customized letters. A label name known to MS Word MailMerge mailing label wizard may be used or a template file containing the field names Line1 thru Line5 for each record to be printed. If a...
3
6284
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this computer has drivers installed for this printer, and this printer is shared for the network. Question 1:
29
15427
by: FredBear | last post by:
I am just coming to grips with php, Dreamweaver and MySQL and I want to make a facility available for the members of the group I am creating my web site for. I want them to be able to print-out a list of address labels, using standard Avery labels, on their home PC's using the data from my MySQL tables. I am not yet sufficiently au fait with php to manage to code it myself so I wondered if anybody knew of any Dreamweaver extensions, add-ins...
0
2052
by: jinsatoemo | last post by:
Hello guys,i'm new here,nice to meet you all :-) I need some help in access,particularly in printing to label printers.I've developed a program that generate labels to print to a label printer(Datamax E-4203).The problem is,the label prints to that printer but it doesn't print fast(print 1 label,pause 1 sec,print 1 label,pause again and so on).If I'm using a commercial label maker program like Teklynx Labelview,the label will print very fast...
0
2172
by: jianxin9 | last post by:
Hi everyone, I don't have a lot of experience with ASP and I was hoping someone could help me. I want to use our ASP form along with some javascript code to create a form where our patrons can select which department they will send the form to (we are trying to consolidate forms). This is what I have so far, but when I test the form, I keep getting this error message: Mailing Failed... Error is: FromAddress Property cannot be blank. You...
5
2793
by: Ron | last post by:
Hi All, I've got a report that prints mailing labels. It utilizes a routine that asks the number of labels to skip, the number of each label to print, and then prints. It works really well on a print preview. But,when I print to the printer it disregards the number of labels to skip. I preview all the reports I've got and then have a little printer icon to click on if the user wants to actually print (my attempt at saving trees)....
0
7857
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8220
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7981
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8222
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6632
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5396
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1457
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.