NORBERT said:
Need to limit the number of lines a text box.
eg:
line1 <return>
line2 <return>
line3 <return>
line4 <return>
the total characters typed are 20 less than the Field
Size=200.
Count the number of Carriage returns in the text box:
Function CountCharInString(strIn As String, strChar As String) As Integer
' Counts occurrences of a character in a string
' Arvin Meyer - 12/14/1999
Dim intInstr As Integer
Dim intRet As Integer
intInstr = 0
intRet = 0
Do
intInstr = InStr(intInstr + 1, strIn, strChar)
If intInstr > 0 Then intRet = intRet + 1
Loop While intInstr > 0
CountCharInString = intRet
End Function
And use the count like this:
Sub TestBoxToCount_BeforeUpdate(Cancel As Integer)
If CountCharInString(Me.[TestBoxToCount],Chr(13) & Chr(10)) = 4 Then
MsgBox "You have reached the end of your string"
Cancel = True
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access