concatenate fields

A

accessuser1308

I do not know if this can be done easily....

I have made a database for keeping track of the pictures I take. I have a
field (memo) [people] where I enter any people that are present in the
picture (ex. Person1, Person2, etc). Is there a way that I can put a single
combo box on the form (which will contain a list of all the people I may
photograph) such that when I select a name it will add it to the memo field
[people]. Then, if I select a second name from the combo box it will add a
comma, a space, and then the second name and so on for each name chosen.

I am completely stuck, so any help would be appreciated.
Thank you
 
A

accessuser1308

Hi Al,

Thank you for your quick response. The code you gave me does almost exactly
what I want it to do. The first entry has a comma and a space before it
though. Is there a way to have the first name added to the box and only
subsequent names to be separated by a comma and a space?

Thank you

Al Campagna said:
accessuser1308,
Use the AfterUpdate event of the combo (ex. combo name = cboPeople and
memo name = memPeople).

memPeople = memPeople & ", " & cboPeople

As each name is selected, it is concatenated onto whatever is in
memPeople (seperated by a comma).

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."

accessuser1308 said:
I do not know if this can be done easily....

I have made a database for keeping track of the pictures I take. I have a
field (memo) [people] where I enter any people that are present in the
picture (ex. Person1, Person2, etc). Is there a way that I can put a
single
combo box on the form (which will contain a list of all the people I may
photograph) such that when I select a name it will add it to the memo
field
[people]. Then, if I select a second name from the combo box it will add
a
comma, a space, and then the second name and so on for each name chosen.

I am completely stuck, so any help would be appreciated.
Thank you
 
F

fredg

Hi Al,

Thank you for your quick response. The code you gave me does almost exactly
what I want it to do. The first entry has a comma and a space before it
though. Is there a way to have the first name added to the box and only
subsequent names to be separated by a comma and a space?

Thank you

Al Campagna said:
accessuser1308,
Use the AfterUpdate event of the combo (ex. combo name = cboPeople and
memo name = memPeople).

memPeople = memPeople & ", " & cboPeople

As each name is selected, it is concatenated onto whatever is in
memPeople (seperated by a comma).

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."

accessuser1308 said:
I do not know if this can be done easily....

I have made a database for keeping track of the pictures I take. I have a
field (memo) [people] where I enter any people that are present in the
picture (ex. Person1, Person2, etc). Is there a way that I can put a
single
combo box on the form (which will contain a list of all the people I may
photograph) such that when I select a name it will add it to the memo
field
[people]. Then, if I select a second name from the combo box it will add
a
comma, a space, and then the second name and so on for each name chosen.

I am completely stuck, so any help would be appreciated.
Thank you

Test if the [MemPeople] is null.

If IsNull([MemPeople]) Then
[MemPeople] = [cboPeople]
Else
[memPeople] = [memPeople] & ", " & [cboPeople]
End If

However, this is not the correct method for doing something like this.

Have a separate table and enter each person's name as an individual
record in this table.

Table name: tblInThePicture
Field Name PictureID Number datatype Long field Size Duplicates
OK
Field Name InPicture Text datatype

The table is the recordsource for a sub-form of your current Picture
form, linked to the main form by the PictureID field.

Each person in the picture is added as a new record to this table
field linked by the PictureID to the main tble.
 
A

accessuser1308

Al,

Thank you very much. I took your advice about the table and subform. This
is exactly what I wanted.

Thank you

fredg said:
Hi Al,

Thank you for your quick response. The code you gave me does almost exactly
what I want it to do. The first entry has a comma and a space before it
though. Is there a way to have the first name added to the box and only
subsequent names to be separated by a comma and a space?

Thank you

Al Campagna said:
accessuser1308,
Use the AfterUpdate event of the combo (ex. combo name = cboPeople and
memo name = memPeople).

memPeople = memPeople & ", " & cboPeople

As each name is selected, it is concatenated onto whatever is in
memPeople (seperated by a comma).

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html
"Find a job that you love... and you'll never work a day in your life."

I do not know if this can be done easily....

I have made a database for keeping track of the pictures I take. I have a
field (memo) [people] where I enter any people that are present in the
picture (ex. Person1, Person2, etc). Is there a way that I can put a
single
combo box on the form (which will contain a list of all the people I may
photograph) such that when I select a name it will add it to the memo
field
[people]. Then, if I select a second name from the combo box it will add
a
comma, a space, and then the second name and so on for each name chosen.

I am completely stuck, so any help would be appreciated.
Thank you

Test if the [MemPeople] is null.

If IsNull([MemPeople]) Then
[MemPeople] = [cboPeople]
Else
[memPeople] = [memPeople] & ", " & [cboPeople]
End If

However, this is not the correct method for doing something like this.

Have a separate table and enter each person's name as an individual
record in this table.

Table name: tblInThePicture
Field Name PictureID Number datatype Long field Size Duplicates
OK
Field Name InPicture Text datatype

The table is the recordsource for a sub-form of your current Picture
form, linked to the main form by the PictureID field.

Each person in the picture is added as a new record to this table
field linked by the PictureID to the main tble.
 

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