Combine fields in a text box

G

Guest

I have a form where I have the contacts Title, Firstname and Surname.

At the moment I have them in three separate controls, but i want to create a
text field where the three elements (Title, First Name and Surname) are
concatenated with one space between the fields.

So instead of having Mr Dylan Moran.
The screen could read Mr Dylan Moran. With nice spacing in between the fields

The fields are in the recordset that controls the data on the form.

Any help?
 
K

Kevin Hughes

Dylan Moran said:
I have a form where I have the contacts Title, Firstname and Surname.

At the moment I have them in three separate controls, but i want to create
a
text field where the three elements (Title, First Name and Surname) are
concatenated with one space between the fields.

So instead of having Mr Dylan Moran.
The screen could read Mr Dylan Moran. With nice spacing in between the
fields

The fields are in the recordset that controls the data on the form.

Any help?


Make a new text box, with the control source set to = [Title] & " " &
[Firstname] & " " & [Surname]

Obviously, correct the field names to represent what's in your table
HTH
Kevin
 
M

Marshall Barton

Dylan said:
I have a form where I have the contacts Title, Firstname and Surname.

At the moment I have them in three separate controls, but i want to create a
text field where the three elements (Title, First Name and Surname) are
concatenated with one space between the fields.

So instead of having Mr Dylan Moran.
The screen could read Mr Dylan Moran. With nice spacing in between the fields

The fields are in the recordset that controls the data on the form.


Use the concatenation operator in a text box expression to
combine the values:

=[Title] & " " & [FirstName] & " " & [SurName]

You could also use the + concatenation operator to propogate
a Null value. For example, if the first name might not be
specified:

=[Title] & (" " + [FirstName]) & " " & [SurName]

You should really read the Help chapter on expressions.
especially the part about operators.
 
G

Guest

Thanks for that. I am currently reviewing the help.

Lots of goodies to learn again. I forgot about how to use them. Has been a
while.



Marshall Barton said:
Dylan said:
I have a form where I have the contacts Title, Firstname and Surname.

At the moment I have them in three separate controls, but i want to create a
text field where the three elements (Title, First Name and Surname) are
concatenated with one space between the fields.

So instead of having Mr Dylan Moran.
The screen could read Mr Dylan Moran. With nice spacing in between the fields

The fields are in the recordset that controls the data on the form.


Use the concatenation operator in a text box expression to
combine the values:

=[Title] & " " & [FirstName] & " " & [SurName]

You could also use the + concatenation operator to propogate
a Null value. For example, if the first name might not be
specified:

=[Title] & (" " + [FirstName]) & " " & [SurName]

You should really read the Help chapter on expressions.
especially the part about operators.
 
G

Guest

And am now tidying up my reports as well.

Thanks guys, layout is much better and professional looking.



Dylan Moran said:
Thanks for that. I am currently reviewing the help.

Lots of goodies to learn again. I forgot about how to use them. Has been a
while.



Marshall Barton said:
Dylan said:
I have a form where I have the contacts Title, Firstname and Surname.

At the moment I have them in three separate controls, but i want to create a
text field where the three elements (Title, First Name and Surname) are
concatenated with one space between the fields.

So instead of having Mr Dylan Moran.
The screen could read Mr Dylan Moran. With nice spacing in between the fields

The fields are in the recordset that controls the data on the form.


Use the concatenation operator in a text box expression to
combine the values:

=[Title] & " " & [FirstName] & " " & [SurName]

You could also use the + concatenation operator to propogate
a Null value. For example, if the first name might not be
specified:

=[Title] & (" " + [FirstName]) & " " & [SurName]

You should really read the Help chapter on expressions.
especially the part about operators.
 
G

Guest

Kevin-

This is definately helpful to me as well

however, my code is such: = [Name First] & " " & [Name Last]
and I am still getting errors. I'd bet the farm this is due to the spaces
between "Name" and "First" and "Last." what can I do to get around this?

Thanks muchly
/amelia



Kevin Hughes said:
Dylan Moran said:
I have a form where I have the contacts Title, Firstname and Surname.

At the moment I have them in three separate controls, but i want to create
a
text field where the three elements (Title, First Name and Surname) are
concatenated with one space between the fields.

So instead of having Mr Dylan Moran.
The screen could read Mr Dylan Moran. With nice spacing in between the
fields

The fields are in the recordset that controls the data on the form.

Any help?


Make a new text box, with the control source set to = [Title] & " " &
[Firstname] & " " & [Surname]

Obviously, correct the field names to represent what's in your table
HTH
Kevin
 
G

Guest

I have something similar and maybe you can help me....
I have two fields one has and employee 3 and the other has the name (last,
first)
I would like to combine than and was able to do that thanks to this string,
however what I now would like to do is only have the employee # and last
name. All are separted by a , between last and first...is this possible at
all?

Marshall Barton said:
Dylan said:
I have a form where I have the contacts Title, Firstname and Surname.

At the moment I have them in three separate controls, but i want to create a
text field where the three elements (Title, First Name and Surname) are
concatenated with one space between the fields.

So instead of having Mr Dylan Moran.
The screen could read Mr Dylan Moran. With nice spacing in between the fields

The fields are in the recordset that controls the data on the form.


Use the concatenation operator in a text box expression to
combine the values:

=[Title] & " " & [FirstName] & " " & [SurName]

You could also use the + concatenation operator to propogate
a Null value. For example, if the first name might not be
specified:

=[Title] & (" " + [FirstName]) & " " & [SurName]

You should really read the Help chapter on expressions.
especially the part about operators.
 
T

tlyczko

Some ideas:

1. Base the form on a query and use an expression in the query to
concatenate the field values.

2. Look at this link, it will show how the work can be done for you:
http://mvps.org/access/modules/mdl0008.htm
also see: http://mvps.org/access/modules/mdl0004.htm
It takes a while to get the hang of they work but they are very good

Also there is this function for when some of these items are blank or
null, use this in a query:
Expression: Mid("12"+[control name] & ", "+[control name],3)

I think you can add more fields than just two, I found this Mid item on
one of the Access NGs.

Good luck, Tom
 
S

Sam Hobbs

You should create a new question (thread) and explain your requirements
better in it. If you have already created a new thread then people will
probably answer that question and then it is a waste of time for people to
answer here. In this thread, I don't understand what you are asking here.

Note that VB has the LTrim, RTrim and Trim Functions; I don't know if they
are relevant for you. VB also has the InStr, Split and Join Functions.
 

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