Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adjustable Mailing Lists 3

Status
Not open for further replies.

perrymans

IS-IT--Management
Nov 27, 2001
1,340
0
0
US
I need to make a report that producing a mailing list for a directory. The problem is, not all fields have information. Some might be:

Name
Business
Business Address
Business Phone
Home Phone

And others could be:

Name
Business
Home Address
Home Phone

etc.

What is the best way to make a report for this?

I was thinking of something like grouping on the member's ID field and having a subform that was continuous.

Any thoughts?

Thanks. Sean.
 
Make a combined field concatenating the values.

Here is an example from Northwind data base using the Customers table
Code:
"SELECT  [CompanyName] & Chr(13) & Chr(10) & [Address] & Chr(13) & Chr(10) & [City]+ " " & [Region]+ " " & [PostalCode] AS Mailing
FROM Customers"

The results look like

Mailing

Alfreds Futterkiste
Obere Str. 57
Berlin 12209"

Ana Trujillo Emparedados y helados
Avda. de la Constitución 2222
México D.F. SA 05021"

Antonio Moreno Taquería
Mataderos 2312
05023

Around the Horn
120 Hanover Sq.
London England

Each one has a different piece of information missing.

You may notice that in certain places I use a "+" instead of and "&"

The reason is that a
null + a string = null

if you do
firstName & " " & MI & ". " & lastName

If you do not pass it a Middle intitial you would get
John . Smith
If you rewrite the above to
firstName & " " + MI & ". " & lastName
you get
John Smith
and if you pass it a MI
John A. Smith
 
This is actually a Reports forum question, not a Forms question. What do you want to happen? Are the fields displayed across or down?

IMHO, never use a form or subform for printing.

You can set text boxes to Can Shrink if you don't want them to take up space on your report.

Duane
Hook'D on Access
MS Access MVP
 
MajP,
I'd replace this:
firstName & " " + MI & ". " & lastName
with this:
firstName & " " & (MI + ". ") & lastName

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes, sorry that was a typo. The important point many people do not know

string & null = string
string + null = null

very handy in doing concatenations.
 
Thanks. Neither the concatenation nor the Can shrink wil work.

There are fields that ae blank, and not always concatenatable. The can shrink still leaves noticable gaps in the result.

I will have to figure something out using a continuous detail style format.

Thanks. Sean.
 
Can you give an example? Especially an example of a field/s that can not get concatenated. I thought the concatenation example addresses blank fields.
 
Code:
Name
Business Name
Business Address
Home Address

Let's say this is the format. Not all records have a Business Name and Address. This leaves blanks in the result like:

Code:
Name

Home Address

I would like to be able to automatically adjust for these types of missing pieces of information and produce:

Code:
Name 1
Business Name
Business Address
Home Address

Name 2
Home Address

Thanks. Sean.
 
Code:
Public Function concatAdd(varName As Variant, varBuisNam As Variant, varBuisAdd As Variant, varHomeAdd As Variant) As String
  If Trim(varName & " ") = "" Then
    Exit Function
  Else
    concatAdd = varName
  End If
  If Not Trim(varBuisNam & " ") = "" Then
    concatAdd = concatAdd & vbCrLf & varBuisNam
  End If
  If Not Trim(varBuisAdd & " ") = "" Then
    concatAdd = concatAdd & vbCrLf & varBuisAdd
  End If
  If Not Trim(varHomeAdd & " ") = "" Then
    concatAdd = concatAdd & vbCrLf & varHomeAdd
  End If
End Function
query or calculated control

Code:
SELECT concatAdd([Name],[BuisnessName],[BuisnessAddress],[HomeAddress]) AS mailing
FROM tblAddresses;

input
Code:
Name	BuisnessName	BuisnessAddress	HomeAddress
John Smith	Acme	123 1st Street	456 Main Street
Bob Smith		123 2nd Street	678 Front Street
Jan Smith			891 Elm Street
Rob Smith	ABC Printing	678 3rd Street

output
Code:
mailing
John Smith
Acme
123 1st Street
456 Main Street

Bob Smith
123 2nd Street
678 Front Street

Jan Smith
891 Elm Street

Rob Smith
ABC Printing
678 3rd Street
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top