myself said:
2. Set textbox.MaxLength to 86
Well, in general one more than you need.
I also checked whether that fails, if the underlying field of the dbf/cursor only allows 85 (or in general maxlength-1) and it does not fail. Whether the maxlength is longer than the field controlsource allows or is unlimited, you can enter more text and it will be immediately truncated once you leave the textbox.
What matters for the functioning of the interactivechange is simply, that you can allow an additional space character which just allows the text cursor to be after the (maxlength-1)th text character and so you get the behavior you want to see about the text cursor and continuing to write does nothing. The user can leave with ENTER or right arrow or TAB, of course, and in Lostfocus I'd perhaps remove the additional space or don't even put it in there. Actually, it's optional, the text cursor can still be at SelStart = maxlength-1, if there is no space. You could just visually show you're at the maxlength when you also set SelLength=1, then the space would be shown inverted.
And, last not least, you can also "ring the bell" by doing
So maybe try
Code:
If This.SelStart >= This.MaxLength-1
This.Value = Left(This.Value,This.MaxLength-1)+" "
This.SelStart = This.MaxLength-1
This.SelLength = 1
?? chr(7)
Endif
in conjunction with this in the valid event to remove this space:
Code:
If Len(This.Value) = This.Maxlength
This.Value = Left(This.Value,This.MaxLength-1)
Endif
or don't add it by using this variant of ineractivechange:
Code:
If This.SelStart >= This.MaxLength-1
This.Value = Left(This.Value,This.MaxLength-1)
This.SelStart = This.MaxLength-1
This.SelLength = 0
?? chr(7)
Endif
In both cases the maxlength still has to be set one higher than you want the actual limitation, the last position is needed to get the text cursor on that extra position and thereby not overwrite what was entered into the last position by continuing to type.
In many offices I know the workstations will have no sound, so no one disturbs others with noise, so a visual hint of getting to maxlength with the additional inverted space is a good choice, I think, you may remove the ?? chr(7), too.
Chriss