ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cancel Key Press Event (https://www.excelbanter.com/excel-programming/405499-cancel-key-press-event.html)

DZ

Cancel Key Press Event
 
How can I cancel the Key Press Event in a Excel 97 Combo Box from Controls
Toolbar.

The Event Procedure is

Private Sub cboField_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

End Sub

What I want to do is prevent the user from entering any text into the combo
box, because the combo box is for making selections only, not entering new
values.

In Access, I would use the Docmd.Cancel Event, but there should be a way to
accomplish the same thing in Excel

Thank you

Dave Peterson

Cancel Key Press Event
 
I think it would make more sense (as a user) to change the .style property to
fmStyleDropDownList (it won't allow new entries) and change the .matchrequired
property to true (and maybe change the .matchentry to fmMatchEntryComplete (to
help choose from the list)).

But you could use
KeyAscii= 0
(but that doesn't seem very user friendly to me.)


DZ wrote:

How can I cancel the Key Press Event in a Excel 97 Combo Box from Controls
Toolbar.

The Event Procedure is

Private Sub cboField_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

End Sub

What I want to do is prevent the user from entering any text into the combo
box, because the combo box is for making selections only, not entering new
values.

In Access, I would use the Docmd.Cancel Event, but there should be a way to
accomplish the same thing in Excel

Thank you


--

Dave Peterson

DZ

Cancel Key Press Event
 
Thank you

DZ


All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com