Link to home
Start Free TrialLog in
Avatar of Altaf Patni
Altaf PatniFlag for India

asked on

How to reject delete key from datacombo

Hi
i am using following code, to just select text from datacombo. but delete key still working..
i wanted to reject delete key .. Please assist me.

Private Sub Check_Arrow(ByRef code As Integer)
    Select Case code

        Case 37 To 40               ' arrow keys are ok

        Case Else                   ' Reject any other key.
            code = 0
    End Select
End Sub

Open in new window

Avatar of Alfredo Luis Torres Serrano
Alfredo Luis Torres Serrano
Flag of United States of America image

What code areyou passing th that funciton?
Avatar of Altaf Patni

ASKER

Private Sub cb_city1_KeyPress(KeyAscii As Integer)

    MsgBox KeyAscii
    
    Call Check_Arrow(KeyAscii)

end sub

Open in new window

where are you getting the keycode???
Replace with

Private Sub cb_city1_KeyPress(KeyAscii As Integer)

    if KeyAscii <> 46
        Call Check_Arrow(KeyAscii)
   else
        KeyAscii = 24
    endif

end sub
tried but delete key still working..
i want to prevent user to use delete key or delete contain from datacombo
datacombo or combobox binded to data???
Try this

Private Sub cb_city1_KeyPress(KeyAscii As Integer)

    If KeyAscii = 46 Then
        ' "Cancel" the keystroke  
        KeyAscii = 0
else
        Call Check_Arrow(KeyAscii)
    End If

end sub
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial