W
Wayne
I am using SQL Server 2000 behind a MS Access 2000
application.
I am trying to limit the number of characters a user may
enter in a text box on a form.
The field in the SQL table is nvarchar with a length of
4000.
Here is the code I use to test the number of characters in
the text box. I get the error on the line .Text = Left
(.Text, maxi) I am trying to remove the string that is
too long and replace it with a string that will match the
maximum length allowed. I pass in the textbox control and
its maximum allowed length.
Public Sub CheckMax(ByVal maxi As Integer, myctl As
Control)
With myctl
If Len(.Text) > maxi Then
DoCmd.Beep
MsgBox "You have exceeded " & maxi & "
characters", vbInformation, ""
.Text = Left(.Text, maxi)
'Set the cursor at the end of the text...
myctl.SelStart = maxi
End If
End With
Set myctl = Nothing
This code worked well untill I changed the length of the
field in SQL Server from 255 to 4000.
Thanks,
Wayne
application.
I am trying to limit the number of characters a user may
enter in a text box on a form.
The field in the SQL table is nvarchar with a length of
4000.
Here is the code I use to test the number of characters in
the text box. I get the error on the line .Text = Left
(.Text, maxi) I am trying to remove the string that is
too long and replace it with a string that will match the
maximum length allowed. I pass in the textbox control and
its maximum allowed length.
Public Sub CheckMax(ByVal maxi As Integer, myctl As
Control)
With myctl
If Len(.Text) > maxi Then
DoCmd.Beep
MsgBox "You have exceeded " & maxi & "
characters", vbInformation, ""
.Text = Left(.Text, maxi)
'Set the cursor at the end of the text...
myctl.SelStart = maxi
End If
End With
Set myctl = Nothing
This code worked well untill I changed the length of the
field in SQL Server from 255 to 4000.
Thanks,
Wayne