How to Lock or Do not Edit Combo Box

C

cclark

Is it possible to have a combo box where user can select what is in the
combo box but the user can not edit what is in the combo box?

I tried the 3 properties listed but

allow edits = No -- Locks the list whereas you can not choose the
items in the combo list.

allow deletions = No -- Still allows user to edit what is in the combo
box

allow additions = No -- Still allows user to edit what is in the combo
box.

Thanks

cclark
 
R

Rick Brandt

cclark said:
Is it possible to have a combo box where user can select what is in
the combo box but the user can not edit what is in the combo box?

I tried the 3 properties listed but

allow edits = No -- Locks the list whereas you can not
choose the items in the combo list.

allow deletions = No -- Still allows user to edit what is in the
combo box

allow additions = No -- Still allows user to edit what is in the
combo box.

If what you mean is can you force them to choose from the list and not manually
enter something that is not shown in the list then the property you are looking
for is LimitToList. Set that to true.

Otherwise you will have to clarify because "editing what is in the ComboBox" can
be interpreted more than one way.
 
A

Al Campagna

cclark,
Not sure if I understand but...
Sounds like you need to lock the combo (ex. name cboMyCombo) after a value has been
selected.
Set the combo Enabled property to Yes in design mode..

Use this code on the AfterUpdate event of cboMyCombo...
cboMyCombo.Enabled = IsNull(cboMyCombo)
cboMyCombo.Locked = Not IsNull(cboMyCombo)
Use this code in the OnCurrent event of the form itself...
cboMyCombo.Enabled = IsNull(cboMyCombo)
cboMyCombo.Locked= Not IsNull(cboMyCombo)

On a new record, when cboMyCombo is null, it will be anabled for selection.
After the selection, the combo will lock.
As you browse from record to record, the form will lock/unlock the combo according to
whether it's null or not null.

But... be aware that this method allows the user one shot at the combo selection. If
they select the wrong value, it's too late... the combo will lock.
You might want to consider using a checkbox to to disable/lock the combo (as well as the
checkbox itself), after the user has determined that cboMyCombo is correct. Just figure
out what works best for you, or tailor this "concept" to suit...

--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
C

cclark

Rick Brandt said:
If what you mean is can you force them to choose from the list and not manually
enter something that is not shown in the list then the property you are looking
for is LimitToList. Set that to true.

Otherwise you will have to clarify because "editing what is in the ComboBox" can
be interpreted more than one way.

Thanks Rick,

I currently have LimitToList set to true. Right now user receives message
stating "text is not in item list". But what I really want to do is lock the
combo box so that user can not add additional letters to current selections
or user can not put in any other info. I would like to lock the combo box so
that user can not manually enter anything into the combo box.

ie.

if combo box list is: A
B
C

currently users can manually enter A1 into the combo box and receive
"text is not in item list". But I would like user to not have the ability to
edit the field at all. They should only be able to choose from the list and
not be able to edit.

Thanks,

cclark
 
R

Rick Brandt

cclark said:
I currently have LimitToList set to true. Right now user receives
message stating "text is not in item list". But what I really want to
do is lock the combo box so that user can not add additional letters
to current selections or user can not put in any other info. I would
like to lock the combo box so that user can not manually enter
anything into the combo box.

ie.

if combo box list is: A
B
C

currently users can manually enter A1 into the combo box and
receive "text is not in item list". But I would like user to not have
the ability to edit the field at all. They should only be able to
choose from the list and not be able to edit.

There are no property combinations that allow for that, but you can fake it.
Make your ComboBox only as wide as the DropDown "arrow" and place a TextBox
beside it (Locked = True). Now there will be no place for the user to type in
at all on the actual ComboBox. They can drop the list down and make a selection
only. Set the ControlSource of the TextBox so it is the same as that of the
ComboBox and their choice will be displayed after they make a selection.
 
C

cclark

Rick Brandt said:
There are no property combinations that allow for that, but you can fake it.
Make your ComboBox only as wide as the DropDown "arrow" and place a TextBox
beside it (Locked = True). Now there will be no place for the user to type in
at all on the actual ComboBox. They can drop the list down and make a selection
only. Set the ControlSource of the TextBox so it is the same as that of the
ComboBox and their choice will be displayed after they make a selection.

Thanks for the advice. This option may work for me with a little
modification. Currently my combo box uses Row Source Type = Value List, but
the list only contains 4 choices. So, I guess if I create a table in the
database with the four choices, then I will be able to use your method using
ControlSource.

Thanks,

cclark
 
R

Rick Brandt

cclark said:
Thanks for the advice. This option may work for me with a little
modification. Currently my combo box uses Row Source Type = Value
List, but the list only contains 4 choices. So, I guess if I create a
table in the database with the four choices, then I will be able to
use your method using ControlSource.

Try it as is. It will work.
 
C

cclark

Rick Brandt said:
Try it as is. It will work.


Rick,

Thanks. It worked to a degree. I asked how this can be done if combo box
list is: A, B, C
Your method works for the above data, thanks.

My actual list is like: Compressors, Equipment

So if I make ComboBox only as wide as the DropDown "arrow" , I won't get
whole word Compressors... only Co.

Thanks anyway. Sorry about not giving a real representation of data earlier.

cclark
 
R

Rick Brandt

cclark said:
Rick,

Thanks. It worked to a degree. I asked how this can be done if combo
box list is: A, B, C
Your method works for the above data, thanks.

My actual list is like: Compressors, Equipment

So if I make ComboBox only as wide as the DropDown "arrow" , I won't
get whole word Compressors... only Co.

Thanks anyway. Sorry about not giving a real representation of data
earlier.

You don't understand. You aren't supposed to see anything in the ComboBox when
you make it only as narrow as the arrow button. That is the point of the
separate TextBox bound to the same field. THAT is where you will see your
selection after making it.
 
R

Rick Brandt

I just realized you might be talking about the width of the drop down list. By
default that is the same width as the ComboBox itself, but you can use the
ListWidth property to make the drop down list as wide as you like.
 
C

cclark

Rick Brandt said:
You don't understand. You aren't supposed to see anything in the ComboBox when
you make it only as narrow as the arrow button. That is the point of the
separate TextBox bound to the same field. THAT is where you will see your
selection after making it.

After I make the ComboBox as narrow as the arrow button, when I click on the
arrow in design view, the list drops down below the arrow but the list is
only as wide as the narrow button. Are you saying that the list from the
ComboBox shouldn't drop down at all?

cclark
 
R

Rick Brandt

cclark said:
After I make the ComboBox as narrow as the arrow button, when I click
on the arrow in design view, the list drops down below the arrow but
the list is only as wide as the narrow button. Are you saying that
the list from the ComboBox shouldn't drop down at all?

Did you see my other response? Here it is again...

I just realized you might be talking about the width of the drop down list. By
default that is the same width as the ComboBox itself, but you can use the
ListWidth property to make the drop down list as wide as you like.
 
C

cclark

Rick Brandt said:
Rick Brandt wrote:
I just realized you might be talking about the width of the drop down list. By
default that is the same width as the ComboBox itself, but you can use the
ListWidth property to make the drop down list as wide as you like.

Thanks Rick, ListWidth worked.

cclark
 
C

cclark

Rick Brandt said:
Did you see my other response? Here it is again...

I just realized you might be talking about the width of the drop down list. By
default that is the same width as the ComboBox itself, but you can use the
ListWidth property to make the drop down list as wide as you like.

Thanks Rick, ListWidth worked.

cclark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top