I have a VBapp with a textbox that the user enters numbers into. If they press the return key, I want a sub called. The following code works fine, except for one thing. When the return key is pressed, I get a "ding" sound indicating an error (although the textbox still retains the number entered). I put in an error handler and noticed that an error is generated with each key stroke. The error no. returned is "0" and there is no error description. Can anyone help me to get rid of this annoying bug?Code:Private Sub txtEdit_KeyPress(KeyAscii As Integer) 'Each keystroke generates an error - text is still put into textbox 'On Error GoTo errhandler 'errhandler: 'MsgBox Err.number & " - " & Err.Description Select Case KeyAscii Case vbKeyReturn ' When the user hits the return key ' this code'll move the next cell or row. Call DataEntryCell If booMsgBox = True Then booMsgBox = False End If With ActiveGrid If .col + 1 <= .Cols - 1 Then .col = .col + 1 Active_FlxCell.col = .col ElseIf .row + 1 <= .Rows - 1 Then .row = .row + 1 Active_FlxCell.row = .row '.col = 0 Else .row = 1 .col = 0 End If DataEntryBox ActiveGrid End With End Select End Sub




Reply With Quote