combo box - can use drop down, but not edit?

R

radioheadbutt

Is there a way of using a combo box on a form, where the user cannot edit the
fields [or even try to] , but still use the arrow on the box to select a
record? So basically if they put their cursor on the box, they cannot change
the text, but they can still use the drop down arrow.

Currently, if the user tries to change a value within the combo box, an
error message pops - "The value you entered doesn't meet the validation rule
defined for the field or control." I would like to have no error message at
all.
 
O

Ofer

On the OnKeyDown Property of the combo you can write the code

Private Sub ComboName_KeyDown(KeyCode As Integer, Shift As Integer)
KeyCode = 8 ' change it to back space
End Sub

That will delete the key that the user trying to type
 
R

radioheadbutt

I attempted this but it didn't work for me...

I tried Msg.box (" error ") within the OnKeyDown property, and it sort of
works now. If someone changes the text, they receive the "error" box [which
is what I want], but then it goes to the end/debug box...

Any way of not receiving the end/debug box?

Ofer said:
On the OnKeyDown Property of the combo you can write the code

Private Sub ComboName_KeyDown(KeyCode As Integer, Shift As Integer)
KeyCode = 8 ' change it to back space
End Sub

That will delete the key that the user trying to type


radioheadbutt said:
Is there a way of using a combo box on a form, where the user cannot edit the
fields [or even try to] , but still use the arrow on the box to select a
record? So basically if they put their cursor on the box, they cannot change
the text, but they can still use the drop down arrow.

Currently, if the user tries to change a value within the combo box, an
error message pops - "The value you entered doesn't meet the validation rule
defined for the field or control." I would like to have no error message at
all.
 
J

John Vinson

Is there a way of using a combo box on a form, where the user cannot edit the
fields [or even try to] , but still use the arrow on the box to select a
record? So basically if they put their cursor on the box, they cannot change
the text, but they can still use the drop down arrow.

Currently, if the user tries to change a value within the combo box, an
error message pops - "The value you entered doesn't meet the validation rule
defined for the field or control." I would like to have no error message at
all.

If you're using a combo to select a record, its Control Source should
- MUST! - be blank; i.e. the combo should not be bound to any field.
If you also set (or leave, it's the default) the combo's Limit to List
property to True it will only let them select values within the
combo's row source.


John W. Vinson[MVP]
 
Top