Have a combo box list Field captions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • opmandrake
    New Member
    • Feb 2010
    • 5

    Have a combo box list Field captions

    Heya guys. Might be a simple question, but for the life of me I couldn't hit the right search string in google and find what I'm looking for, so I guess I'll bother all of you instead :p

    Alright, the thing is I'd like to create a combo box who's got a table as a source for its Field List. So far so good - the drop-down options are showing up as "fldName", "fldAddress ", etc, cuz I'm a good little boy and set my db up with a naming convention and everything.

    However, I'd rather the options showed up as their captions, so instead of a list full of "fldXXXX"'s , I'd have something like "Name", "Address" etc, which are the field Captions in the table itself.

    Is this doable either using VBA or a SELECT statement in the combo box's "Row Source" field? If the former, be aware I'm a total retard when it comes to coding so please be gentle...

    Thanks in advance!
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    It sounds like you have the Row Source Type of the Combo Box set to Field List, while it needs to be set to Table/Query.

    Comment

    • opmandrake
      New Member
      • Feb 2010
      • 5

      #3
      Hi ADezii , thanks for the reply.

      Hmm I tried that...no luck though, sorry. The list is then populated with all the values of those particular fields (Joe;Steve;etc) what I have in mind is more like a list of all the fields themselves (Name/Age/Address/etc) instead of the field names (fldName/fldAge/fldAddress...)

      For reference I'm using it as a part of a filter...the user selects the field he wants on the first combo box, then enters the text he wants to match on a related text box.

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        Hi. When a combo box is populated from a table/query it takes its column headings from the field names in the table/query. In checking the properties of a combo box I have not found any way so far in which this can be overridden.

        The simplest solution is to change the rowsource of the combo from the table itself to a query on that table. In that query you can alias the fieldnames to be whatever you want:

        Code:
        SELECT fldName as Name, fldAge as Age, fldAddress as Address, ...,
        FROM tblYourTableName ... etc
        Although it would also be possible to create a Querydef on the fly in VBA code to do this the work involved is not worth the effort on a use-once basis. Manually defining a simple one-off query - which you can do directly from the combo's rowsource property in edit mode - will do the job just as well and with much less effort.

        -Stewart

        Comment

        Working...