Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101

    Unanswered: Concatenating 2 fields into a Combo Box

    I have a combo box with a select statement like this:

    select lname,fname,ampid from employee order by lname

    When an employee is selected, I would like for the combo box named compsign to display the first and last name. I have added code for the after update event that looks like this:

    Private Sub compsign_AfterUpdate()
    Dim rst As ADODB.Recordset

    Set rst = New ADODB.Recordset
    With rst
    .ActiveConnection = CurrentProject.Connection
    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    End With
    rst.Open "select fname,lname From Employee where ampid = '" & Me!compsign & "' "
    Me!compsign = rst("FNAME") + " " + rst("LNAME")

    Set rst = Nothing
    End Sub


    When the after update code runs, the combo box is blank. I have put a break in the code and checked the values. me!compsign has the first and last name stored in it, but in the form it is blank. What can I do to fix this?

    Thanks,

    Sherry

  2. #2
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    what is it you really want to do? do you want to make first record selected in your combobox when the form first opens?
    ghozy.

  3. #3
    Join Date
    Sep 2004
    Posts
    161
    I never use adodb but may be can you read a record ....

  4. #4
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101
    I want the combo box to come up null in the form, when the user clicks on the arrow and selects their first and last name, I want the first and last name to be in the combo box.


    Thanks,

    Sherry

  5. #5
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    ah you only see the lname in the box. is that what bothers you?
    then you should change select command of your combobox to:

    select lname+ ", " +fname as FullName, ampid from employee order by lname

    ofcourse don't forget to fix combobox' bound column after that.
    ghozy.

  6. #6
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101
    Well that was easy! I did not know you could concatenate in a Select statement. Thank you VERY much!


    Sherry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •