debbie1212
Programmer
I am trying to make sure a text box accepts no more than 6 numbers. However I keep getting the following error message:
"[Microsoft][ODBC SQL Server Driver] String data, right truncation Error #: -2147217833"
I did the following and nothing works:
1. Changed the MaxLength property to 6.
2. Put frmCriteria2.txtFirstBox.MaxLength=6 in Form_Load, txtFirstBox_KeyPress and cmdPrint_Click.
I also tried to put the following text in at the cmdPrint_Click and txtFirstBox_LostFocus functions:
If Len(.txtFirstBox.Text) > 6 Then
Beep
MsgBox "The Stored Box Number cannot be more than 6 digits long", vbOKOnly
.txtFirstBox.SetFocus
End If
This is the code for the text box:
Private Sub txtFirstBox_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
KeyAscii = KeyAscii
If Not cmdPrint.Enabled Then
cmdPrint.Enabled = True
End If
Case 10
txtLastBox.SetFocus
Case 8
KeyAscii = KeyAscii
Case 13
txtLastBox.SetFocus
Case Else
KeyAscii = 0
End Select
End Sub
Whatever I try I still get the above error message.
I would prefer to have the box only accept 6 characters and no more. Why won't the MaxLength property for this text box work?
If I can't get it working that way then I would like to add the MsgBox that says they can't enter more than 6 digits but unfortunately I can't get that to work either.
Thanks!
"[Microsoft][ODBC SQL Server Driver] String data, right truncation Error #: -2147217833"
I did the following and nothing works:
1. Changed the MaxLength property to 6.
2. Put frmCriteria2.txtFirstBox.MaxLength=6 in Form_Load, txtFirstBox_KeyPress and cmdPrint_Click.
I also tried to put the following text in at the cmdPrint_Click and txtFirstBox_LostFocus functions:
If Len(.txtFirstBox.Text) > 6 Then
Beep
MsgBox "The Stored Box Number cannot be more than 6 digits long", vbOKOnly
.txtFirstBox.SetFocus
End If
This is the code for the text box:
Private Sub txtFirstBox_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
KeyAscii = KeyAscii
If Not cmdPrint.Enabled Then
cmdPrint.Enabled = True
End If
Case 10
txtLastBox.SetFocus
Case 8
KeyAscii = KeyAscii
Case 13
txtLastBox.SetFocus
Case Else
KeyAscii = 0
End Select
End Sub
Whatever I try I still get the above error message.
I would prefer to have the box only accept 6 characters and no more. Why won't the MaxLength property for this text box work?
If I can't get it working that way then I would like to add the MsgBox that says they can't enter more than 6 digits but unfortunately I can't get that to work either.
Thanks!