Print a Single Label

J

Janet

Folks
One of my users lost an un-backed-up (aaaggghhhh) database, which he was
using to print labels. I don't know Access at all, but I've managed to
re-load information by importing from a spreadsheet, and have used the Label
Wizard to create the labels.

My big problem now is that I don't know how to print only 1 label. I've
read through other people's questions, but can't understand the coding. Can
someone please let me know, in really simple language for a complete Access
novice, how I can set up the database so it prints only the label that is
selected.

Thanks very much for any help.
 
J

Jeff Boyce

Janet

"... only the label that is selected" ... selected where?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

Ken Sheridan

Janet:

Lets say the label report is based on a table of contacts with a unique
primary key column ContactID. If you have a form based on the same table for
instance then you can add a button to the form to print a label for the
current contact by putting code along the following lines in its Click event
procedure:

Const REPORTNAME = "[YourlabelReporNameGoesHere]"
Dim strCriteria AS String

' first make sure current record is saved
Me.Dirty = False

strCriteria = "ContactID = " & Me.ContactID

' print the report filtered to current contact
DoCmd.OpenReport REPORTNAME, WhereCondtion:=strCriteria

If you are not familiar with entering code in event procedures this is how
its done:

Select the button in form design view and open its properties sheet if its
not already open. Then select the On Click event property in the properties
sheet. Click on the 'build' button; that's the one on the right with 3 dots.
Select 'Code Builder' in the dialogue, and click OK. The VBA window will
open at the event procedure with the first and last lines already in place.
Enter the lines of code between these two existing lines.

There are other ways of achieving the same end. You could use an unbound
dialogue form with a combo or list box from which to select a contact for
instance. Post back if you need further help on that or any other method.

Ken Sheridan
Stafford, England
 
J

Janet

Ken
That's a brilliant reply, thanks very much - I'll give this a go, and will
come back if I need any extra help.
--
Janet


Ken Sheridan said:
Janet:

Lets say the label report is based on a table of contacts with a unique
primary key column ContactID. If you have a form based on the same table for
instance then you can add a button to the form to print a label for the
current contact by putting code along the following lines in its Click event
procedure:

Const REPORTNAME = "[YourlabelReporNameGoesHere]"
Dim strCriteria AS String

' first make sure current record is saved
Me.Dirty = False

strCriteria = "ContactID = " & Me.ContactID

' print the report filtered to current contact
DoCmd.OpenReport REPORTNAME, WhereCondtion:=strCriteria

If you are not familiar with entering code in event procedures this is how
its done:

Select the button in form design view and open its properties sheet if its
not already open. Then select the On Click event property in the properties
sheet. Click on the 'build' button; that's the one on the right with 3 dots.
Select 'Code Builder' in the dialogue, and click OK. The VBA window will
open at the event procedure with the first and last lines already in place.
Enter the lines of code between these two existing lines.

There are other ways of achieving the same end. You could use an unbound
dialogue form with a combo or list box from which to select a contact for
instance. Post back if you need further help on that or any other method.

Ken Sheridan
Stafford, England

Janet said:
Folks
One of my users lost an un-backed-up (aaaggghhhh) database, which he was
using to print labels. I don't know Access at all, but I've managed to
re-load information by importing from a spreadsheet, and have used the Label
Wizard to create the labels.

My big problem now is that I don't know how to print only 1 label. I've
read through other people's questions, but can't understand the coding. Can
someone please let me know, in really simple language for a complete Access
novice, how I can set up the database so it prints only the label that is
selected.

Thanks very much for any help.
 
K

Ken Sheridan

Janet:

Just noticed a typo. You'll probably have guessed that's what it should be,
but just in case…

WhereCondtion should be WhereCondition

Ken Sheridan
Stafford, England

Janet said:
Ken
That's a brilliant reply, thanks very much - I'll give this a go, and will
come back if I need any extra help.
--
Janet


Ken Sheridan said:
Janet:

Lets say the label report is based on a table of contacts with a unique
primary key column ContactID. If you have a form based on the same table for
instance then you can add a button to the form to print a label for the
current contact by putting code along the following lines in its Click event
procedure:

Const REPORTNAME = "[YourlabelReporNameGoesHere]"
Dim strCriteria AS String

' first make sure current record is saved
Me.Dirty = False

strCriteria = "ContactID = " & Me.ContactID

' print the report filtered to current contact
DoCmd.OpenReport REPORTNAME, WhereCondtion:=strCriteria

If you are not familiar with entering code in event procedures this is how
its done:

Select the button in form design view and open its properties sheet if its
not already open. Then select the On Click event property in the properties
sheet. Click on the 'build' button; that's the one on the right with 3 dots.
Select 'Code Builder' in the dialogue, and click OK. The VBA window will
open at the event procedure with the first and last lines already in place.
Enter the lines of code between these two existing lines.

There are other ways of achieving the same end. You could use an unbound
dialogue form with a combo or list box from which to select a contact for
instance. Post back if you need further help on that or any other method.

Ken Sheridan
Stafford, England

Janet said:
Folks
One of my users lost an un-backed-up (aaaggghhhh) database, which he was
using to print labels. I don't know Access at all, but I've managed to
re-load information by importing from a spreadsheet, and have used the Label
Wizard to create the labels.

My big problem now is that I don't know how to print only 1 label. I've
read through other people's questions, but can't understand the coding. Can
someone please let me know, in really simple language for a complete Access
novice, how I can set up the database so it prints only the label that is
selected.

Thanks very much for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top