Print Label for each selection in listbox (1 Viewer)

shenty

Registered User.
Local time
Today, 16:59
Joined
Jun 8, 2007
Messages
119
I have a report that prints address labels for contacts in a database. It works ok for printing individually but i want to 'batch print' some labels (xmas envelopes!).

I have a form with a multi select listbox setup with the filtered contacts i want to print. I also have a button for 'Print ALL' and a button for 'Print Selected'.

I can't figure what code would do for each button. ! :mad:

In a fashion the Print ALL works but it is not adding a 'line feed' between each record. In other words instead of printing each address on a seperate label it is overlapping to previous labels if they are not full.

Could anyone guide me in the right direction, i'll even add you to my Xmas Card list haha.

Many thanks in advance.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:59
Joined
Feb 19, 2002
Messages
43,322
Use the label wizard to create the label "report". As long as you choose the correct label spec, the labels will format correctly.
 

shenty

Registered User.
Local time
Today, 16:59
Joined
Jun 8, 2007
Messages
119
Hi

I have also tried the label wizard but that too prints multiple labels on each sheet.

How would i get it to print individual labels on seperate sheets only for items selected in listbox.

Cheers
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:59
Joined
Feb 19, 2002
Messages
43,322
If each label is a "sheet", you need to define a custom paper size rather than use the label wizard or if you use the label wizard, define the page as one label long and one label wide.

Here's a simple way to use multiple selections to filter a report:
Code:
    Dim i As Variant
    Dim strIN As Variant
    Dim strWhere as String
    
    strIN = ""
    For Each i In lstSelect.ItemsSelected
        strIN = strIN & lstSelect.ItemData(i) & ","
    Next i
    strIN = Left(strIN, Len(strIN) - 1) ' remove trailing comma.
    strWhere = "YourField IN(" & strIN & ")"
Then use strWhere as the where argument for the OpenReport method.
This example assumes that the values being accumulated are numeric. If they are text, they will need to be enclosed in quotes.
 

Users who are viewing this thread

Top Bottom