Putting Text Into Combo Box

JamesJoey

Registered User.
Local time
Today, 18:22
Joined
Dec 6, 2010
Messages
628
I have a combo box with an associated label.

I want to eliminate the label and have the label text be part of the row source of the combo box.

The combo box is based on a select statement.

Can this be done??
James
 
I want to eliminate the label and have the label text be part of the row source of the combo box.
Why would you want to do that :confused:
 
Because I wish to.
 
Last edited:
If the SELECT statement for the combo is

SELECT tblX.Field1 FROM tblX

you can modify it as

SELECT 'label caption' & tblX.Field1 FROM tblX

where 'label caption' is whatever you want to enter.
 
Because I wish to.:banghead:

James

That is not a very polite reply.

Here you have someone who is willing to help you and simply asked a question that may be beneficial.

We don't get paid here at AWF. We do it simply to help others who are new at the game.

I hope your future replies contain some respect.
 
James

That is not a very polite reply.

Here you have someone who is willing to help you and simply asked a question that may be beneficial.

We don't get paid here at AWF. We do it simply to help others who are new at the game.

I hope your future replies contain some respect.
I thought much the same Rain. Still this OP is not the first and unfortunately will probably not be the last.
 
One would think that an apology would have been made by now.

Such is Life.
 
Didn't realize this would get such negative responses.

Sorry to all for my unpolitic post.

It won't happen again.

James
 
Didn't realize this would get such negative responses.

Sorry to all for my unpolitic post.

It won't happen again.

James
Thank you James.

So, did the solution offered by shoji fulfill your requirement or are you still looking for a solution.
I'm still curious about why you might want to do this. The reason I asked initially was because I have never found a need for this and thought that perhaps I had misunderstood the requirement.
 
It was much simpler than I thought.

I simply placed a label over the combo boxes, leaving the cbo's down arrow exposed!

Now when I open the cbos the contents show and then after making a selection the label re-appears. Just what I wanted.

I'm doing this to save some space in the header of the form... just cosmetic.

Thanks,
James
 
In the future, you can also consider manually (sort of) populating the rows of your combo box. I've done this before to provide an 'all entries' default.

This is the pertinent code from a larger OnLoad event, used to populate a combo box that allows the user to select to show either 'All Actions' or a specific chosen action. (It's part of an activity log - image attached.)

Code:
    [COLOR=seagreen]'Delete any existing rowsource data from cbo_Actions.[/COLOR]
    Me.cboActions.RowSource = ""
    Me.cboActions.Value = Null
 
    [COLOR=seagreen]'Add the "All Actions" value to ActionList.[/COLOR]
    ActionList.AddItem "0;" & ACTION_DEFAULT
 
    [COLOR=seagreen]'Create a query containing all the actions listed in dbo_tblActions.[/COLOR]
    SQL = "SELECT dbo_tblActions.ActionID, dbo_tblActions.ActionName FROM dbo_tblActions ORDER BY [ActionName];"
 
    [COLOR=seagreen]'Open a recordset based on SQL.[/COLOR]
    Set rs = CurrentDb.OpenRecordset(SQL, dbOpenSnapshot)
 
    With rs
       [COLOR=seagreen]'Ensure the pointer is at the beginning of the file.[/COLOR]
        .MoveFirst
       [COLOR=seagreen]'Loop through the recordset.[/COLOR]
        Do Until .EOF
            [COLOR=seagreen]'Add the ActionID and ActionName from the current record.[/COLOR]
            ActionList.AddItem .Fields("ActionID").Value & ";" & .Fields("ActionName")
           [COLOR=seagreen]'Move to the next record.[/COLOR]
            .MoveNext
        Loop
    End With
 
   [COLOR=seagreen]'Set the default value for cboActions to 0.[/COLOR]
    Me.cboActions.Value = 0
ACTION_DEFAULT is just a constant with a value of "All Actions".
The query I drop into the string variable SQL is a basic row source query.

You could do the same using your label text rather than my 'All Actions' - just make sure that anything using that combo box checks to make certain a value has actually been selected.
 

Attachments

  • FeeSchedLogFilters_Redacted.JPG
    FeeSchedLogFilters_Redacted.JPG
    68.3 KB · Views: 66
James

Good to hear from you.

Welcome to the forum.
 
@Frothingslosh: Did you miss the addition of "All" to a combo by using a UNION?

SELECT CustomerID, CompanyName FROM Customers UNION Select Null as AllChoice , "(All)" as Bogus From Customers ORDER BY CustomerID;

from: http://access.mvps.org/access/forms/frm0043.htm

Have to admit, that solution never occurred to me. If those filters on the form I showed didn't have a tiny, tiny list (less than 5 for one, 20 for the other), I'd definitely use that instead to speed things up.
 

Users who are viewing this thread

Back
Top Bottom