Results 1 to 15 of 15
  1. #1
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164

    Combo Box Defailut text


    I have a combo box on a form that is bound to a table. When the user selects an item in the combo box a corresponding form will open.
    I am using the combo boxes label to describe the contents of the list. I don't really like the label thing and was wondering if it is possible to have the combo box show text (depicting the contents)in the combo box itself, and once the list has been used as above, then the combo box should return to the state it was prior to the selection.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Attached is a jpg of a sample combo with multi-fields. I'm not sure if that's what you're asking for.

  3. #3
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    NO, not at all. What i want is the label for the combo box to be inside the combo box.

    For instance: if a value is required to be selected form a combo box, a label such as "Please select", should be visible within the box. This value does not form part of the list that the user would select from.

    I also want the box to return to "Please select" immediatly after the selection is made.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    if a value is required to be selected form a combo box, a label such as "Please select", should be visible within the box
    Hmm? To me, if you want to see "Please select" in the combo, it would be part of the Value list.
    There are many examples (vba) for adding a "display message" at the top or bottom of a value list.

    Good luck.

  5. #5
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    Quote Originally Posted by orange View Post
    There are many examples (vba) for adding a "display message" at the top or bottom of a value list.

    Good luck.
    Thanks, i am battling to find an example. if you have a link i would appreciate you sharing.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Something like this is the approach
    using a UNION Query. I'm using a mythical field ModelName
    and a mythical table YourModelTable. you'll have to adjust accordingly.


    SELECT ModelName
    FROM YourModelTable
    WHERE YourModelTable.Make = Forms!Formname!Comboname
    UNION
    SELECT "<Please Select>"
    FROM YourModelTable

  7. #7
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    Hi, Is there anyway to do this using code ?, i am setting up my DB to have a language setting and depending on the language chosen the "display message" will have to change accordingly.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Doesn't that mean that if you choose a different language, not only does the
    "display message" change, but the values you display for products,cities (whatever data is in the combo) would change language appropriately also?

    What control do you plan to use to change language?

  9. #9
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    No, the data captured is for the most part not language dependant. That that is language dependant is inserted by the user self and as such will be in their language of choice.

    The only item captured that will be in english that is language dependant is dates.

    I will have a check on start up that checks for languge prefences, a list of labels is held in a table, and for each form on opening the form checks language preference and adjust captions accordingly.

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Here's a sample db in Acc2003. It has a Form with an OptionGroup for selecting a language, and a combo to display Data and an instruction. The data and instruction are presented in the language selected by the user. The instruction is sorted to the top of the combo. The instruction is added to the combo by means of Union queries.

    It may not have features you need, but the basics of the instruction in various user selectable languages should be applicable to your situation.

    I hope this is useful to you.
    Last edited by orange; 06-07-2011 at 10:55 AM. Reason: clarification

  11. #11
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    I could not get this to work:

    SELECT ModelName
    FROM YourModelTable
    WHERE YourModelTable.Make = Forms!Formname!Comboname
    UNION
    SELECT "<Please Select>"
    FROM YourModelTable
    I have attached my SQL statement
    SELECT tbl_functions.Function, tbl_functions.FormName, tbl_functions.MenuNumber
    FROM tbl_functions
    WHERE (((tbl_functions.MenuNumber)=2)) ORDER BY tbl_functions.FormName; UNION
    SELECT "<Please Select>"
    FROM tbl_Functions

  12. #12
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    Quote Originally Posted by orange View Post
    Here's a sample db in Acc2003. It has a Form with an OptionGroup for selecting a language, and a combo to display Data and an instruction. The data and instruction are presented in the language selected by the user. The instruction is sorted to the top of the combo. The instruction is added to the combo by means of Union queries.

    It may not have features you need, but the basics of the instruction in various user selectable languages should be applicable to your situation.

    I hope this is useful to you.
    I LIKE......I am very sure this will come in handy

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Did you try the database I sent?
    If you look at the AfterUpdate event of the Frame2, you'll see how the union queries are used to build/set the Rowsource of the combo.

    The code there, string sql, is almost identical to the code in your question.

    SELECT tbl_functions.Function, tbl_functions.FormName, tbl_functions.MenuNumber
    FROM tbl_functions
    WHERE (((tbl_functions.MenuNumber)=2)) ORDER BY tbl_functions.FormName; UNION
    SELECT "<Please Select>"
    FROM tbl_Functions
    In a union query the number of fields must be consistent. The semicolon in the middle would be a problem also.

    I would try (untested)

    select * from
    (SELECT tbl_functions.Function
    , tbl_functions.FormName
    , tbl_functions.MenuNumber
    FROM tbl_functions
    UNION
    SELECT "<Please Select>" as function,"" as FormName,2 as menuNumber
    FROM tbl_functions)
    WHERE tbl_functions.MenuNumber=2
    ORDER BY tbl_functions.FormName

  14. #14
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    Thanks, the new code worked, although, i would like to have "please select" show even when the combo box is not in focus.

  15. #15
    hargro is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    4
    I believe I have just been fiddling with the exact thing you describe. After some googling I realized there were no elegant ways of achieving what I wanted, so I came up with this (horribly ugly but functional) solution:

    I made a combobox and an unassociated label. The label has no background or border, is positioned in exactly the same place as the combobox and is drawn on top (bring to front).

    Two event-procedures:

    On click; hide the label and set focus to the combobox:
    Code:
    Private Sub Label_Click()
        Me.Label.Visible = False
        Me.Combobox.SetFocus
    (    Me.Combobox.Dropdown)
    End Sub
    When you leave the combobox; if anything is selected, the label stays hidden. If the box is empty, the label becomes visible.
    Code:
    Private Sub Combobox_LostFocus()
        If IsNull(Me.Combobox) Then
            Me.Label.Visible = True
        Else
            Me.Label.Visible = False
        End If
    End Sub
    It's not a satisfying solution, but it definitely works and looks professional as long as you don't see what's going on behind the curtains (Note that if the combobox is cleared by another script, the label will stay hidden unless that's being dealt with elsewhere)

    Best regards,
    hargro

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update a text box based on a combo box
    By fleschnj in forum Access
    Replies: 1
    Last Post: 11-08-2010, 12:14 PM
  2. Replies: 3
    Last Post: 06-29-2010, 12:08 PM
  3. Can you wrap text in a Combo Box ?
    By softspoken in forum Forms
    Replies: 5
    Last Post: 03-21-2010, 05:32 AM
  4. Filter by combo box & text box?
    By sparkyboy2406 in forum Forms
    Replies: 2
    Last Post: 02-24-2010, 04:20 PM
  5. Combo box to text box
    By kc21supra in forum Access
    Replies: 4
    Last Post: 08-21-2009, 01:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums