Solved

Urgent!!!! Combo Box Dilemma!!!

Posted on 2002-03-24
9
184 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:jay_acbo
9 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6893072
What is the error appears? any code avaible? ..
0
 
LVL 1

Expert Comment

by:Neo78
ID: 6893078
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.
0
 
LVL 5

Accepted Solution

by:
raizon earned 40 total points
ID: 6893098
the way I do this in SQL is build my SQL statment like so.

sql = "SELECT lname + fname As fullName from Table"
rs.Open sql, conn

If not rs.EOF then
  while not rs.EOF
    cmbData.AddItem rs("fullName")
  wend
End If

but basically the concept is combining the two fields from your database in your sql statment and aliasing them as a single field.
0
 
LVL 1

Expert Comment

by:CodeWizrd
ID: 6893122

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.

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:jay_acbo
ID: 6893466
actually, i'm using a data combo control....
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6893492
Then what's the problem? ..
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6893670
then use raizon idea: sql = "SELECT lname + fname As fullName from Table"
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7637808
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
0
 

Expert Comment

by:SpideyMod
ID: 7753630
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now