Combining firstname and lastname in combo box

  • Follow


Hi,

i have a main table which consist of firstname and last name in 2 separate 
fields. What i'm trying to do is that when selecting the name in the combo 
box, I would like  the full name to appear.

Eg

Field 1 -- Field 2 -- Combo box
John --Smith -- John, Smith

Can someone help please.

Thanks

Yogin 
0
Reply Utf 2/9/2010 3:51:01 PM

Yogin -

Update the recordsource for the combo box, then adjust the properties of the 
combo box to show what you want.  You can show only the combined name using 
column widths of 0" for the first two fields.

The recordsource query would be something like this:

SELECT FName, LName, FName & ", " & LName
From tableName

-- 
Daryl S


"Yogin" wrote:

> Hi,
> 
> i have a main table which consist of firstname and last name in 2 separate 
> fields. What i'm trying to do is that when selecting the name in the combo 
> box, I would like  the full name to appear.
> 
> Eg
> 
> Field 1 -- Field 2 -- Combo box
> John --Smith -- John, Smith
> 
> Can someone help please.
> 
> Thanks
> 
> Yogin 
0
Reply Utf 2/9/2010 4:04:09 PM


Hi Daryl,

Thanks for the quick reply. I'm a complete newbie on Access and learning 
with support from people on this forum.

When I click properties for this combo box to input the fomula, I cannot see 
the recordsouce, I do see controlsource. 

I tried to put the formula in there and I get an error.

This is what I put in controlsouce field of the combo box
SELECT FirstName, LastName, FirstName & ", " & LastName
From tblColleague

clearly i'm doing something wrong?

Can you help please

Thanks

Yogin

"Daryl S" wrote:

> Yogin -
> 
> Update the recordsource for the combo box, then adjust the properties of the 
> combo box to show what you want.  You can show only the combined name using 
> column widths of 0" for the first two fields.
> 
> The recordsource query would be something like this:
> 
> SELECT FName, LName, FName & ", " & LName
> From tableName
> 
> -- 
> Daryl S
> 
> 
> "Yogin" wrote:
> 
> > Hi,
> > 
> > i have a main table which consist of firstname and last name in 2 separate 
> > fields. What i'm trying to do is that when selecting the name in the combo 
> > box, I would like  the full name to appear.
> > 
> > Eg
> > 
> > Field 1 -- Field 2 -- Combo box
> > John --Smith -- John, Smith
> > 
> > Can someone help please.
> > 
> > Thanks
> > 
> > Yogin 
0
Reply Utf 2/9/2010 5:08:01 PM

On Tue, 9 Feb 2010 07:51:01 -0800, Yogin <Yogin@discussions.microsoft.com>
wrote:

>Hi,
>
>i have a main table which consist of firstname and last name in 2 separate 
>fields. What i'm trying to do is that when selecting the name in the combo 
>box, I would like  the full name to appear.
>
>Eg
>
>Field 1 -- Field 2 -- Combo box
>John --Smith -- John, Smith
>
>Can someone help please.
>
>Thanks
>
>Yogin 

Yor table design may need some rethinking! Names are NOT unique: I once worked
at a university with a professor John W. Vinson. You should have a unique
PersonID primary key in the table.

That said, you can create a Query based on your table. In the first column of
the query grid put the unique ID field (this is what the combo should be
storing); in the second column put

FullName: [Field1] & ", " & [Field2]

to construct a string "John, Smith" (is that really what you want?? More
common would be "John Smith" or "Smith, John").

Put the two fields in the third and fourth columns in the order that you want
the names sorted, and select Ascending as the sort order.

You can then use this Query as the row source of your Combo Box. If you set
the column count to 2 and the ColumnWidths property to

0.0";1.5"

you will *see* the name, but the combo will store the ID.
-- 

             John W. Vinson [MVP]
0
Reply John 2/9/2010 5:49:08 PM

The SQL goes into the Row Source property since there is no Record Source on 
combo boxes.

-- 
Duane Hookom
Microsoft Access MVP


"Yogin" wrote:

> Hi Daryl,
> 
> Thanks for the quick reply. I'm a complete newbie on Access and learning 
> with support from people on this forum.
> 
> When I click properties for this combo box to input the fomula, I cannot see 
> the recordsouce, I do see controlsource. 
> 
> I tried to put the formula in there and I get an error.
> 
> This is what I put in controlsouce field of the combo box
> SELECT FirstName, LastName, FirstName & ", " & LastName
> From tblColleague
> 
> clearly i'm doing something wrong?
> 
> Can you help please
> 
> Thanks
> 
> Yogin
> 
> "Daryl S" wrote:
> 
> > Yogin -
> > 
> > Update the recordsource for the combo box, then adjust the properties of the 
> > combo box to show what you want.  You can show only the combined name using 
> > column widths of 0" for the first two fields.
> > 
> > The recordsource query would be something like this:
> > 
> > SELECT FName, LName, FName & ", " & LName
> > From tableName
> > 
> > -- 
> > Daryl S
> > 
> > 
> > "Yogin" wrote:
> > 
> > > Hi,
> > > 
> > > i have a main table which consist of firstname and last name in 2 separate 
> > > fields. What i'm trying to do is that when selecting the name in the combo 
> > > box, I would like  the full name to appear.
> > > 
> > > Eg
> > > 
> > > Field 1 -- Field 2 -- Combo box
> > > John --Smith -- John, Smith
> > > 
> > > Can someone help please.
> > > 
> > > Thanks
> > > 
> > > Yogin 
0
Reply Utf 2/9/2010 6:33:01 PM

Yogin -

Sorry, the row source, not record source is where the SQL goes...
-- 
Daryl S


"Yogin" wrote:

> Hi Daryl,
> 
> Thanks for the quick reply. I'm a complete newbie on Access and learning 
> with support from people on this forum.
> 
> When I click properties for this combo box to input the fomula, I cannot see 
> the recordsouce, I do see controlsource. 
> 
> I tried to put the formula in there and I get an error.
> 
> This is what I put in controlsouce field of the combo box
> SELECT FirstName, LastName, FirstName & ", " & LastName
> From tblColleague
> 
> clearly i'm doing something wrong?
> 
> Can you help please
> 
> Thanks
> 
> Yogin
> 
> "Daryl S" wrote:
> 
> > Yogin -
> > 
> > Update the recordsource for the combo box, then adjust the properties of the 
> > combo box to show what you want.  You can show only the combined name using 
> > column widths of 0" for the first two fields.
> > 
> > The recordsource query would be something like this:
> > 
> > SELECT FName, LName, FName & ", " & LName
> > From tableName
> > 
> > -- 
> > Daryl S
> > 
> > 
> > "Yogin" wrote:
> > 
> > > Hi,
> > > 
> > > i have a main table which consist of firstname and last name in 2 separate 
> > > fields. What i'm trying to do is that when selecting the name in the combo 
> > > box, I would like  the full name to appear.
> > > 
> > > Eg
> > > 
> > > Field 1 -- Field 2 -- Combo box
> > > John --Smith -- John, Smith
> > > 
> > > Can someone help please.
> > > 
> > > Thanks
> > > 
> > > Yogin 
0
Reply Utf 2/9/2010 7:13:01 PM

Guy's, Thank You for your help. 

The solution works well.



"John W. Vinson" wrote:

> On Tue, 9 Feb 2010 07:51:01 -0800, Yogin <Yogin@discussions.microsoft.com>
> wrote:
> 
> >Hi,
> >
> >i have a main table which consist of firstname and last name in 2 separate 
> >fields. What i'm trying to do is that when selecting the name in the combo 
> >box, I would like  the full name to appear.
> >
> >Eg
> >
> >Field 1 -- Field 2 -- Combo box
> >John --Smith -- John, Smith
> >
> >Can someone help please.
> >
> >Thanks
> >
> >Yogin 
> 
> Yor table design may need some rethinking! Names are NOT unique: I once worked
> at a university with a professor John W. Vinson. You should have a unique
> PersonID primary key in the table.
> 
> That said, you can create a Query based on your table. In the first column of
> the query grid put the unique ID field (this is what the combo should be
> storing); in the second column put
> 
> FullName: [Field1] & ", " & [Field2]
> 
> to construct a string "John, Smith" (is that really what you want?? More
> common would be "John Smith" or "Smith, John").
> 
> Put the two fields in the third and fourth columns in the order that you want
> the names sorted, and select Ascending as the sort order.
> 
> You can then use this Query as the row source of your Combo Box. If you set
> the column count to 2 and the ColumnWidths property to
> 
> 0.0";1.5"
> 
> you will *see* the name, but the combo will store the ID.
> -- 
> 
>              John W. Vinson [MVP]
> .
> 
0
Reply Utf 2/10/2010 7:18:02 PM

6 Replies
314 Views

(page loaded in 0.356 seconds)

Similiar Articles:
















7/20/2012 2:13:19 PM


Reply: