Count the number of characters being typed live in a memo field

mousemat

Completely Self Taught
Local time
Today, 16:58
Joined
Nov 25, 2002
Messages
233
Hi all

Not been here for a while.

I have a form whereby users type notes into a Memo field which is bound to a table (Doesn't have to be bound, its just bound at the moment!)

What I want to acheive is a running total either upwards or downwards of the number of characters the user has typed into the memo field, either showing the number of characters used or remaining.

I have tried the following code
Code:
=Len([AdditionalInformation])
but this will only give the number of characters used once the focus has changed from the Memo field.

I want to have the user see the display showing characters used or remaining as they type.

Any ideas?
 
In the OnChange of the memo text box you want
Code:
Me.YourTextBoxToDisplayTheCount = Len([AdditionalInformation])

Or, if you want a countdown -
Code:
Me.YourTextBoxToDisplayTheCount = 500 - Len([AdditionalInformation])
500 being changed to the actual number you want to have in the text box.
 
Thanks for your quick reply.

However, I have put the code in the OnChange event of my Memo box and get the following error dialogue

The object doesn't contain the Automation object 'Me'

Am I doing something wrong?
 
Probably - :)

Can you post your code from the OnChange event and what the actual names of your objects are?
 
Code:
Me.MaxNo = 500 - Len([AdditionalInformation])

MaxNo is the unbound textbox on the form that I want to display the counter.

AdditionalInformation is the Memo field where the notes will be typed.
 

Attachments

The problem lies in that you don't type in the code where you typed it in. You should select EventProcedure in that spot and then click the elipsis that appears to the right of it to go into the VBA IDE (Integrated Development Environment). Then, paste the code into that spot.
 
Hold on, there's more. I'll post the entire answer in a sec.
 
You need to actually name your text box for the count of characters MaxNo if you want it to be thus. The text box currently is named Text10.

So, if you can actually get to the EventProcedure and put in this code, after changing the text box to the correct name - it should work:
Code:
Me.MaxNo = 500 - Len(Me.AdditionalInformation.Text)
 
Thanks for that, works a treet. I knew there was something wrong, and not just the name of the text10 box. That was correct in my working copy.
 

Users who are viewing this thread

Back
Top Bottom