Full Version: "the text is too long to be edited"
UtterAccess Forums > Microsoft® Access > Access Forms
Hey all again..
Ok last question of the day.
I have a bound field on a form. Field txtsample. And in the table for that field it is set to a length of 50.
At run time, when a long string is pasted into this field I get this message below.
Oget this "the text is too long to be edited"
I would like to catch this error message and replace it with one of my own.
the problem is... I dont know where its coming from...
In the code I have set up tests to see what it may pass through, and it doesn't passs through the following
How can I make my own error messgae to get rid of that one???
This is error number 2221 and if I remember correctly it happens on the BeforeUpdate event of the text control.
Nope its not catching it... ???
Private Sub txtSample_BeforeUpdate(Cancel As Integer)
Select Case DataErr
Case 2221
Select Case Me.ActiveControl.Name
Case "txtSample"
MsgBox "You cannot enter more than 50 characters"
Response = acDataErrContinue
End Select
End Select
End Sub
I am not sure that particular error can be trapped, even at the form level.
You might need to work with an unbound textbox, and use the AFTERUPDATE event of that unbound box to transfer the first 50 characters to the underlying field. You can use the CHANGE event of the unbound box to warn them/limit them/whatever.
Try the Form's On Error event to trap this one.
Noah - I wish I could but am Unable to catch it with that method..
I think Peters suggestion may have to be the best suited for this issue...
Thank you all for your suggests..
The simple solution is set the field in the table to more.
Is you are limiting it to 50 in the form (via vba) this should not be a major problem.
Then you can verify/force the length in the before update (or even the after update) event
haha ya I would but its not my design, and I have to work within the "limits" given...
BUT for others that might be a good solution.
Danny -

Even if he uses a memo field (since text fields max out at 255), you could still have the problem. Not when typing, but if you try to PASTE something in larger than the field will allow.

And, in A2K at least, I can't find a way to trap this particular error (the form's Error event never fires for this one, nor do any of the control's events, except for keyboard ones if you are pasting via keyboard commands).


Just verified this IS trappable in the form's Error event using Access2002 or greater. But since the OP is using A2000...
Edited by: schroep on Mon Jan 23 17:21:29 EST 2006.
I thought for sure this one would be trappable on the On Error of the form. Learn something new every day frown.gif
Quite frankly, the fact that you can't trap for it seems very odd to me. Looks like it got added after 2K, so I guess it seemed odd to someone at MS, too.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.