Well, you keep asking how to deactivate the Enter button, and it's not too hard to do. I'll be glad to tell you how to do it, but I do wish you would listen to the many people who are telling you that you need to get to the bottom of why these deletions are occurring. If you get in the habit of covering over your mistakes with fixes that don't actually fix anything, eventually some of your code will suffer a catastropic collapse, very possibly triggering the same with your professional reputation.
Now, you have written some sort of code, perhaps in a LostFocus event, that is clearing all your text boxes. (VB won't do what you describe without some sort of help from you.) I suggest you find it and fix it.
Although I don't recommend any more than the other responders that you do this, here is how to disable the enter key, since you asked. As you have surmised, you indeed use the keypress event. However, you do not use the text box's keypress event:
1. Set the form's keypreview property to true.
2. In the Form_Keypress event, add the following:
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
End If
End Sub
Note that if you have set the "Default" property (not the "default property", rather there's a property called default that a number of controls expose) of one of your controls to true (doing this fires the click event of that control when you hit enter), the above will not disable the enter key. Setting the default property takes the enter key out of the list of keys recognized by the keypress event.
HTH
Bob