Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing field

Status
Not open for further replies.

Blondie96

Programmer
Aug 12, 2004
119
US
I have a field cboStartHour which gets it's rowsource from a value list. I want to be able to clear the field if the cancel button is pushed.

Can someone help me with this?

Thanks,

Tamra
 
My mistake, I meant the ESC key. I don't have a cancel button.
 
I'm sure someone can give you the code to handle the escape key, unfortunately I'm off into a meeting now. I did have one thought however, if you want to clear the list rather than just the visible text in the box try:
Code:
cboStartHour.RowSource = ""

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Thank you Harleyquinn,

I got around the issue by adding a blank item to the value list.

Appreciate the help.

Tamra
 
Set form KeyPreview =Yes
Properties > Event > Key Preview
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
        If Screen.ActiveControl = Me.MyComboBox Then
            Me.MyComboBox = ""
        End If
    End If
End Sub
If you want clear the Rowsource then
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
        If Screen.ActiveControl = Me.MyComboBox Then
            Me.MyComboBox.RowSource = ""
        End If
    End If
End Sub

________________________________________
Zameer Abdulla
Visit Me
There is only one perfect child in this world. Every mother has it.
 
Thank you ZmrAbdulla,

I am sure I will be able to use this code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top