Link to home
Start Free TrialLog in
Avatar of jay_acbo
jay_acboFlag for Philippines

asked on

Urgent!!!! Combo Box Dilemma!!!

Hi Guys,

Can I combine two fields, say last name & first name in just one combobox. I am encountering errors trying to do so. Could you please help me with this?

Thanks in advance and Happy Easter
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

What is the error appears? any code avaible? ..
Avatar of Neo78
Neo78

Yes u can....here's a suggestion which u have to modify for it to work for u

With cmbData(0)
    .Clear
    If cRcs.boo_ReadData("LeaveType") Then
      While Not cRcs.rcs_ReadData.EOF
        .AddItem cRcs.rcs_ReadData!TypeOfLeave & _
                 "  : " & cRcs.rcs_ReadData!LeaveDesc & ""
        cRcs.Move NextRecord
      Wend
    End If
End With

cRcs.boo_readData is my function call which is a class module. So based on how u declare your recordset and its connections, u can try replacing mine with yours.
But the main part should look like the line : .AddItem....!TypeOfLeave & _.....

In the example, my table is LeaveType, the two fields are TypeOfLeave and LeaveDesc and combobox is cmbData(0).

Regards.
ASKER CERTIFIED SOLUTION
Avatar of raizon
raizon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

The previous answers are all good, except I would trim the fields when putting them together like so:

cboDropdown.additem trim(firstname) & " " & trim(lastname)

This way, your drop down would contain "Rich Smith" instead of potentially "Rich            Smith           " depending on how your database is set up.

Avatar of jay_acbo

ASKER

actually, i'm using a data combo control....
Then what's the problem? ..
then use raizon idea: sql = "SELECT lname + fname As fullName from Table"
Hi jay_acbo,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept raizon's comment(s) as an answer.

jay_acbo, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange