Concatenating two text fields

A

Andrew Wilkins

I have a form containing two text boxes for FirstName and LastName. What I
would like to do is, when the user enters the two names into the boxes, the
names should be joined and then put into the field FullName. Is this
possible? I have looked around this discussion group and some posts are
similar to this but they all confuse me :(
 
J

John Vinson

I have a form containing two text boxes for FirstName and LastName. What I
would like to do is, when the user enters the two names into the boxes, the
names should be joined and then put into the field FullName. Is this
possible? I have looked around this discussion group and some posts are
similar to this but they all confuse me :(

There should NOT BE a field named FullName in your table.

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

You can set the Control Source of a textbox on this Form (or any other
Form, or on a Report) to

=[FirstName] & " " & [LastName]

or, you can create a Query with a calculated field by typing

FullName: [FirstName] & " " & [LastName]

and use this calculated field in any way you would use a stored table
field (other than updating it of course).


John W. Vinson[MVP]
 
Top