adding (Select One) to the top of a combo box

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

how would one set the text in a combo box to be something like "(Select
One)" instead of just being blank?

Where would you put the expression or code?

TIA,
Eric
 
Depends upon the RowSource that you're using for the combo box, what the
Bound Column is, whether you have Limit To List set to yes or no, whether
the combo box is bound to a field in the form's recordsource or not, and
when you want this to display (when form opens, when a new record is being
created, etc.).
 
OK.
The row source is the following query:
SELECT IssueCategory.IssueCategoryID, IssueCategory.CategoryDescription
FROM IssueCategory ORDER BY [CategoryDescription];

The bound column is 1

Limit to List is YES

I want this to display whenever there is a blank, not yet dirtied form (so
when it opens && when there is a new record)

Thanks!
 
With your properties, you cannot do this in the combo box directly. I think
you can accomplish this more easily if you use a label on top of the combo
box that says "Select One"; you can change the caption of that label
depending upon whether you have a new record, etc. or not.

Otherwise, you would need to use a textbox over the top of the combo box,
and make that visible when you want to show this text. The text box would
have a control source of
="(Select One}"

You would need to use code on the Current event to test if the record is a
new one, and then make the textbox visible if yes; make it invisible if no.

The textbox would need code on its GotFocus event to move the focus to the
combo box, and make the textbox invisible.

--

Ken Snell
<MS ACCESS MVP>


Eric said:
OK.
The row source is the following query:
SELECT IssueCategory.IssueCategoryID, IssueCategory.CategoryDescription
FROM IssueCategory ORDER BY [CategoryDescription];

The bound column is 1

Limit to List is YES

I want this to display whenever there is a blank, not yet dirtied form (so
when it opens && when there is a new record)

Thanks!


Ken Snell said:
Depends upon the RowSource that you're using for the combo box, what the
Bound Column is, whether you have Limit To List set to yes or no, whether
the combo box is bound to a field in the form's recordsource or not, and
when you want this to display (when form opens, when a new record is
being created, etc.).
 
Upon further thought, you could have "{Select One)" be one of the choices in
the dropdown list. You'd need to add it to the list by using a union query
as the row source:

SELECT IssueCategory.IssueCategoryID,
IssueCategory.CategoryDescription,
1 AS SortField
FROM IssueCategory
UNION
SELECT -9999 AS Field1, "(Select One)" AS Field2,
0 AS SField
FROM IssueCategory AS ISSCAT
ORDER BY SortField, IssueCategory.[CategoryDescription];

You then would set the DefaultValue of the combo box to
=[NameOfComboBox].[ItemData](0)

Your code then would have to "know" that a value of -9999 in the combo box
is a "no selection made" value, and would have to tell the user to select an
item from the combo box. Note that the user can select the "(Select One)"
option from the list in this setup.

No textbox would be needed in this setup.
--

Ken Snell
<MS ACCESS MVP>





Ken Snell said:
With your properties, you cannot do this in the combo box directly. I
think you can accomplish this more easily if you use a label on top of the
combo box that says "Select One"; you can change the caption of that label
depending upon whether you have a new record, etc. or not.

Otherwise, you would need to use a textbox over the top of the combo box,
and make that visible when you want to show this text. The text box would
have a control source of
="(Select One}"

You would need to use code on the Current event to test if the record is a
new one, and then make the textbox visible if yes; make it invisible if
no.

The textbox would need code on its GotFocus event to move the focus to the
combo box, and make the textbox invisible.

--

Ken Snell
<MS ACCESS MVP>


Eric said:
OK.
The row source is the following query:
SELECT IssueCategory.IssueCategoryID,
IssueCategory.CategoryDescription FROM IssueCategory ORDER BY
[CategoryDescription];

The bound column is 1

Limit to List is YES

I want this to display whenever there is a blank, not yet dirtied form
(so when it opens && when there is a new record)

Thanks!


Ken Snell said:
Depends upon the RowSource that you're using for the combo box, what the
Bound Column is, whether you have Limit To List set to yes or no,
whether the combo box is bound to a field in the form's recordsource or
not, and when you want this to display (when form opens, when a new
record is being created, etc.).

--

Ken Snell
<MS ACCESS MVP>

how would one set the text in a combo box to be something like "(Select
One)" instead of just being blank?

Where would you put the expression or code?

TIA,
Eric
 
Back
Top