Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Box - display data based on selection (2002)

    Hi all,
    I have searched and found how to create a Combo Box - that when I choose an item from the list on a form, it displays what I want on the rest of the form. This part works fine.
    However, the Combo Box only displays the ID field in the dropdown list.

    The Combo Box should show a list of Hospital floor names like 4 Tower, 5 Tower. Instead, its 1, and 4 - the corresponding [UnitID] numbers.

    I have the
    Row Source Type: Table/Query
    Row Source:SELECT tblYearlyEntry.YearlyID, tblYearlyEntry.Unit FROM tblYearlyEntry;
    Column Count:2
    Column Width:0";1"
    Bound Column: 1
    And have tried many different combinations of these.

    I created the Combo Box on my form with the wizard and chose the "find a record on my form based on a value I select in my Combo Box". (this part works fine)
    The field I am using for the Combo Box comes from a field in my table, then my query, called [Unit]. The field [Unit] is related to it's tblUnit that holds the Unit and UnitID.

    I've tried both -having this [Unit] field as List Box in the tableitself, and not having it as a list box in the table, but it makes no difference. I still only get the UnitID numbers.

    The code for the Combo Box is:
    Private Sub Combo57_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[YearlyID] = " & Str(Nz(Me![Combo57], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    I'm not sure what it all means. Is there something I can change?

    I'd really appreciate if anyone has some guidance for me.
    Thanks!
    Vicky

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Combo Box - display data based on selection (2002)

    In tblYearlyEntry the field Unit is actually a number, and at the moment it is this number that is being displayed.

    If you want the name of the unit displayed, you need to add the table tblUnits to the row source of the combo. Click the three little dots to the right of the Row Source and it will open the query grid. Add the table, and if you have set up relationships, the new table will automatically join, Replace Unit from tblYearlyEntry with the field in tblUnits that actually holds the name.
    Regards
    John



  3. #3
    Star Lounger
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box - display data based on selection (2002)

    Thank you very much, it works great!
    A two day headache for something so simple...
    Vicky

Posting Permissions

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