473,799 Members | 3,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mailing Labels

I need to produce mailing labels every week for staff, but not always for
the same people. I have found a procedure using a filter form which
allows individual names to be selected from a list box which are then
applied to a report for printing.

I have an Employees Table filtered via a query to only show current staff.

My FilterForm is tied to this query and the list box on the filter form
shows surname and forename. I can choose any number of names I require
then click an ApplyFilter command button and my chosen names appear on the
Label Report. Just waht I want.

BUT -- next time I open the filter form there is a name missing. The top
name is missing and when I check the employees table the surname has been
deleted, although all the other information is there. I can easily put it
back. But next time it is deleted again. And if I don't put the first
surname back the next one is deleted.

Can anyone see anything amiss with the following code which would cause
the top surname in the list to be deleted?

Many thanks.

Malcolm Webb
Private Sub btnApplyFilter_ Click()
Dim varItem As Variant
Dim strSurname As String
Dim strFilter As String

' Build criteria string from lstSurname listbox
For Each varItem In Me.lstSurname.I temsSelected
strSurname = strSurname & ",'" & Me.lstSurname.I temData(varItem ) _
& "'"
Next varItem
If Len(strSurname) = 0 Then
strSurname = "Like '*'"
Else
strSurname = Right(strSurnam e, Len(strSurname) - 1)
strSurname = "IN(" & strSurname & ")"
End If

' Build filter string
strFilter = "[Surname:] " & strSurname

' Open the mailing label report and apply the filter.
DoCmd.OpenRepor t "LabelsEmployee Address", acViewPreview
With Reports![LabelsEmployeeA ddress]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Malcolm Webb

Dec 7 '05 #1
1 2526
I see nothing in the code that would delete the first surname in the
listing. However, there are a couple of things you may want to look at.

1) Surnames may have apostrophes in the (i.e. O'Hare). Your code will fail
if that is the case because you are using apostrophes as the delimiter. Try
the following adjustment:

strSurname = strSurname & ",""" & Me.lstSurname.I temData(varItem ) _
& """"

This changed each apostrophe to 2 double quotes. Since double quotes are
string delimiters also, you have to double them up to tell VBA that you
really mean for the double quote to be part of the string instead of a
delimiter. You may actually have to concatenate them in as double quotes if
the IN statement fails with the above. This would be for the same reason as
mentioned above for the apostrophes. The doubled up double quotes will put a
single double quote in the string as part of the string, this may cause a
problem with the IN statement. If so, they will need to be placed into the
string as doubled up double quotes. This would require replacing each
apostrophe with 4 double quotes instead of 2.

2) What if two people have the same surname? It would be better to use a
PersonID field or some other field that uniquely identifies the person.
--
Wayne Morgan
MS Access MVP
"Malcolm Webb" <mf********@yah oo.co.uk> wrote in message
news:me******** *************** *@mfwebb.compul ink.co.uk...
I need to produce mailing labels every week for staff, but not always for
the same people. I have found a procedure using a filter form which
allows individual names to be selected from a list box which are then
applied to a report for printing.

I have an Employees Table filtered via a query to only show current staff.

My FilterForm is tied to this query and the list box on the filter form
shows surname and forename. I can choose any number of names I require
then click an ApplyFilter command button and my chosen names appear on the
Label Report. Just waht I want.

BUT -- next time I open the filter form there is a name missing. The top
name is missing and when I check the employees table the surname has been
deleted, although all the other information is there. I can easily put it
back. But next time it is deleted again. And if I don't put the first
surname back the next one is deleted.

Can anyone see anything amiss with the following code which would cause
the top surname in the list to be deleted?

Many thanks.

Malcolm Webb
Private Sub btnApplyFilter_ Click()
Dim varItem As Variant
Dim strSurname As String
Dim strFilter As String

' Build criteria string from lstSurname listbox
For Each varItem In Me.lstSurname.I temsSelected
strSurname = strSurname & ",'" & Me.lstSurname.I temData(varItem ) _
& "'"
Next varItem
If Len(strSurname) = 0 Then
strSurname = "Like '*'"
Else
strSurname = Right(strSurnam e, Len(strSurname) - 1)
strSurname = "IN(" & strSurname & ")"
End If

' Build filter string
strFilter = "[Surname:] " & strSurname

' Open the mailing label report and apply the filter.
DoCmd.OpenRepor t "LabelsEmployee Address", acViewPreview
With Reports![LabelsEmployeeA ddress]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Malcolm Webb

Dec 7 '05 #2

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

Similar topics

3
4687
by: Mark V. | last post by:
Here's what I have and I'm stumped. I have a table that has several thousand names and addresses. I only want to send to one address in a household. So what I would like to do is create a new column that runs a macro or whatever it takes to flag records so they are housholded. Some records have a Father and son at the same address, so I would only want to generate a count in my query that gives me one record for that household, a head of...
0
338
by: Nothing | last post by:
Is there a module that I can add to Access 2000 or above that I can add so that the end user can do mailing labels on teh fly. I know Access can do mailing labels form teh wizard, but I wanted to have a predefined format and only prompt the end user fo rthe Label type, Avery or what ever, and then model # of the labels, 8810 or what ever. Any one have any ideas?
2
2038
by: Bobbie | last post by:
I am trying to make mailing labels. The zip/postal codes are 9 digits (ex: 40601-0223) I ran a query and put in the input mask 00000/-9999;;_ and it works but when I make the mailing labels and it pulls in the data the dash is missing (Ex: 406010223). Does anyone know how I can get the dash to follow to the labels? I tried using the wizard and I also built them manually. Any suggestions would be appreciated. Thank you,
3
4329
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:...
3
2338
by: Grim Reaper | last post by:
I know this is probably an easy question, but I could not find/figure it out. Basically, I am printing mailing labels with a "Sorting/Grouping" section that groups the label types together. Also, I am using a "Report Header" to show a count of how many total labels that are being printed. Now, my problem is that without the "Report Header", the spacing is perfect. But, when I add the Report Header, it gets shifted downwards and the...
2
1592
by: dougjrs | last post by:
I have a table that has a list of people that I would like to do a mailing to. The table has the fields First Name, Last Name, House number, Street name, City, State, ZipCode. What I would like to do is elimate sending 2 or 3 pieces of mail to the same address. I would like to have some kind of query that would allow me to identify same last name, House, Street Name and create one label with Last Name "Family". I know how to print...
2
13537
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...
1
1035
by: Ravimama | last post by:
Hi Guys, I have to generate mailing labels for selected addresses using crystal reports. I am loading all the names of the vendors in a checked list box. the user will select a few of the vendor names. I want to load the 5 selected vendors in the mailing labels in crystal reoprts. The crystal reports is designed at design time. I have already used a method where in I am trying to get the Ids of the selected vendors in a string, and I...
7
2020
by: Dave | last post by:
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?
4
2036
by: Dr Al | last post by:
I have a project which requires the batch import of customer contact information, print mailing labels for those customers who have their date of first letter field in the database set to null, and update the date of first letter field with the date the mailing labels are printed. I already have a query which checks the date of first letter field, and returns those customers whose date of first letter field is null. How do I setup to...
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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
10490
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
10243
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,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
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
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.