Does anyone know how to code this for vb.net?
Id like to prevent the users from keying in alpha characters.
Private Sub txtRec_KeyPress(KeyAscii As Integer)
If Chr$(KeyAscii) Like "[!0-9" & Chr$(vbKeyBack) & Chr$(46) & "]" Then
If KeyAscii = 13 Then
KeyAscii = 0 get rid of beep
If txtRec.Text > rs.RecordCount Or txtRec.Text < 1 Then
txtRec.Text = rs.AbsolutePosition
Else
rs.Move txtRec.Text - 1, adBookmarkFirst
Call FillForm
End If
Else
KeyAscii = 0 ignore the keystroke
Beep
End If
End If
End Sub
Id like to prevent the users from keying in alpha characters.
Private Sub txtRec_KeyPress(KeyAscii As Integer)
If Chr$(KeyAscii) Like "[!0-9" & Chr$(vbKeyBack) & Chr$(46) & "]" Then
If KeyAscii = 13 Then
KeyAscii = 0 get rid of beep
If txtRec.Text > rs.RecordCount Or txtRec.Text < 1 Then
txtRec.Text = rs.AbsolutePosition
Else
rs.Move txtRec.Text - 1, adBookmarkFirst
Call FillForm
End If
Else
KeyAscii = 0 ignore the keystroke
Beep
End If
End If
End Sub