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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turn on Insert key 1

Status
Not open for further replies.

JAES

Technical User
Jul 25, 2004
100
GB
I found the following code to disable the insert key. What would it be to make sure the insert key is "on"? I do set the key preview to yes in the form.

Thanks, Jeff


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode
Case vbKeyInsert
KeyCode = 0
Case Else
End Select

End Sub
 
How are ya JAES . . .

No code in the event or the removal of the line [blue]KeyCode = 0[/blue]

If your intending to control on/off of Insert, you could set a variable, declared in the declarations section of the form:
Code:
[blue]Private InsOn As Boolean[/blue]
The code in the [blue]KeyDown[/blue] event then reverts to:
Code:
[blue]Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   
   If (KeyCode = vbKeyInsert) And (Not InsOn) Then KeyCode = 0
 
End Sub[/blue]
[blue]Your Thoughts? . . .[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks again AceMan. The code worked great.
 
AceMan, I went back to the form today and the insert key was not on. All I want is for the insert key to be on, where the key strokes write over the existing entry, whenever I'm in this form. I'm not usderstanding the Keycode command obiviously. Does KeyCode = 0 mean turn the insert key off and is there another Keycode, maybe 1 or 0 that turns it on or is that too simple.

I loaded the Private InsOn code in the declarations section of the form, just under the Option Compare Database command. I placed the other code in the keydown event for the form.

Suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top