Solved

Urgent!!!! Combo Box Dilemma!!!

Posted on 2002-03-24
9
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 52

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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
 

Author Comment

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

Expert Comment

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

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 23 hours left to enroll

636 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