Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Urgent!!!! Combo Box Dilemma!!!

Posted on 2002-03-24
9
Medium Priority
?
196 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 53

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 160 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 53

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

715 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