David McAfee
dmcafee at pacbell.net
Mon Nov 14 12:00:50 CST 2005
You can put a label above they text box that reads "75 characters left". In design mode, right-click on the text field in question, then properties. In the events tab, click in the On Change event field. a button with 3 dots will appear, click it. You should now be in the VBA editor. Place the following code (renaming the label and textbox name to those of yours: Private Sub MyTextBoxName_Change() If Len(Me.MyTextBoxName.Text) < 76 Then Me.MyLabelName.Caption = (75 - Len(Me.MyTextBoxName.Text)) & " characters left" Else MsgBox "You have exceeded the amount of characters allowed in this box", , "Too much info!" Me.MyTextBoxName = Left(Me.MyTextBoxName.Text, 75) Me.MyTextBoxName.SelStart = 75 Me.MyLabelName.Caption = "0 characters left" End If End Sub If your form is unbound, or doesn't allow navigation between records then you should be fine with only the code above. If you do allow navigation between records, then you will need to add this line to the On Current event of the FORM, so the correct number of available characters are displayed on the label: Me.MyLabelName.Caption = (75 - Len(Me.MyTextBoxName.Text)) & " characters left" I have a working sample if you need one. Hope this helps, David McAfee -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Tony Septav Sent: Sunday, November 13, 2005 8:24 AM To: accessd at databaseadvisors.com Subject: [AccessD] Trap for Error Hey All Does anyone know how to trap for the error message "The text is too long to be edited", when someone trys to paste text, into a field, that exceeds the maximum characters for that field. I would just like to change the message to something a little more informative for the user, like "The text is too long maximum characters allowed 75" -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com