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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box

Status
Not open for further replies.

JDU

Technical User
Dec 23, 2002
182
US
I have a table in which I am storing 3 fields Last Name, First Name and Middle Name.

On a form I want to show the name as a single value in a combo box.

I know you have to use the recordsource property to populate it but I don't know how to use a SQL statement to do it please help. Here is the code:

cmboFullName.RowSource = Select Fname,Lname,Mname from tblName (I want to show it as FName (space) Mname (space) Lname)
cmboFullName.Requery

Thanks
 
How are ya JDU . . . . .

The [blue]RowSource[/blue] of a [blue]Combobox[/blue] can be a [purple]Table Name[/purple], [purple]Query Name[/purple] or an [purple]SQL[/purple] statement.

To do what you want, you need to set a custom field which concatenates as required.

If you where using a query (based on the table of interest), you would copy/paste the following in an empty column in the field row:
Code:
[blue]FullName: [Fname] & IIf([Mname] Is Null," "," " & [Mname] & " ") & [Lname][/blue]
As SQL in VBA it would be:
Code:
[blue] = "SELECT [tblNames].[NameID], [Fname] & IIf([Mname] Is Null,' ',' ' & [Mname] & ' ') & [Lname] AS FullName FROM tblNames;"
[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks I appreciate this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top