Can I use cboBox.Column(1) to place an initial value in a ComboBox?

DaveRoehrman
DaveRoehrman used Ask the Experts™
on
I am using the following line to place text into a combo box as the form opens.  Column(0) of the combo box is formatted for text.

Me!cboAccountSelect = "Select an Account"        (works fine)
Me!cboAccountSelect.Column(0) = "Select an Account"       (does not work)

I want to display the same text in a combo box whose column(0) has Integer format, and whose column(1) is text.  The following line does not work.  Is there ANY way to accomplish this?

Me!cboAccountSelect.Column(1) = "Select an Account"       (does not work)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Are you trying to choose an entry from the combobox or are you trying to add text to the combo?

Author

Commented:
I am trying to add text.
MIS Liason
Most Valuable Expert 2012
Commented:
DaveRoehrman,

What you are asking is tricky to do.
What makes it tricky to do, is that it violates basic user interface design theory.

The term "Select an Account" should be in the combobox's Label, not added as a value to be selected, in the combobox itself.
In other words, the combox allows you to "Select an account".
So the words "Select and account" should be the Label caption, or in a Label above the combobox, ...it should not be a "Value"  IN the combobox.
Makes sense?
;-)

The only thing that belongs in the combobox is Accounts.
This is because the end user will be selecting the account.

By adding the words "Selct an Account" to the combobox itself, a user can actually select that term.
Then what?

This technique of "adding" values to combobox is typically done for things like "All" or "None".
...Because selecting these values is will actualy select something.
This is also used in some forms for TextBoxes, not comboboxes.
But even then, the value actually "dissapears" upon the user entering the textbox.
This would require even more code in addintion to the VBA Code/SQL neede to add the value in the first place.

So to answer you question, Yes, ...what you are asking can be done, but it is non-standard

In a nutshell, the term "Select an Account" is an instruction, not a value to be selected.
And as such, this term really does not belong in the combobox itself, but outside it.
Make sense?
;-)

JeffCoachman

untitled.JPG
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Why are you trying to do this as the form opens instead of defining the rowsource of the combo box with the value in it?
You cannot assign values to combo box elements in the way you are trying to.

The method of adding a value to the rowsource depends on how the rowsource is defined.

Author

Commented:
I gather from these comments that I can better spend my time conforming to the statndard method, and to accept that this control is designed to start out blank.  I appreciate your time very much.
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
DaveRoehrman,

There is absolutely nothing wrong with a combobox having a default value.

The issue here is three-fold.
1. Depending on the configuration of the combobox, it may not be easy to add a "Display" value, without having a corresponding "Bound Column" Value.
2. The "Interface" considerations I mentioned above.
3. Lastly becaues the combobox can display values as well as let a user enter them.
(as opposed to a listbox that will just display values.)

Like everything in life, there are no "Absolutes". ("You should never do this.", or "You should always do that.")
There are exceptions to every rule.
As Pete will tell you, Design guidelines change every few years or so as technology changes.
Knowing when to break the rules is the key.
;-)
I use the Microsoft "Options" dialog box in many programs as my reference.
You will see that none of the comboboxes display "Instructions", like:
 "Select a ..."
(Screenshots attached)

My general rule is that I look at other professional applications/interfaces.
If I don't ever see the interface I need ever used, I will try not to invent it.
:-)

As I said, I have seen what you are asking for in "TextBoxes" in some web apps.
But a textbox is designed for data entry.
You can have a combobox that simply displays values, and lets you select from among them.

Lastly, and what I should have added to my post, is that what I have stated is my "Opinion", not any universal rule.
;-)

JeffCoachman
untitled01.JPG
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
Just FYI:
To make the default value of a combobox, the "first" value in the list, you can use something like this in the Default value property of the combobox:
=[YourCombobox].[ItemData](0)
Or this in VBA:
Me.YourCombobox.DefaultValue = Me.YourCombobox.ItemData(0)

;-)

Jeff

Author

Commented:
Jeff, I greatly appreciate the complimentary "service after the sale".  It went a long way to clear up what was for me a cloudy issue.
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
LOL!

Someimes I get confused as well:
BoundColumns, Column(0) or Column(1), LimitToList, NotInList, Table/Query, ValueList,...ect
;-)

Jeff

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial