Text Box Character Counter

  • Thread starter ondvirg via AccessMonster.com
  • Start date
O

ondvirg via AccessMonster.com

I have a text box bound to text field I have limited to 155 characters.
That's all the data I want the users to be able to enter. I also have a text
box using the =len() function to return the number of characters to the other
text box.

What I'd like is for this "counter" to refresh with the new count as the user
types in the text. The things I've tried always refresh the whole form so I
can't continually type out a sentence. Is there anyway to accomplish this?
 
J

Jack Leach

I'm not sure what you've tried, but I would start by using the OnChange event
of the control you want to count the characters in, and updating the counter
from there.


Private Sub Textbox1_Change()
Me.txtCounter = Len(Nz(Me.Textbox1.Text, 0))
End Sub

hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
O

ondvirg via AccessMonster.com

Thanks, that works perfectly. Sometimes I'm amazed at how the simple things
puzzle me.

Jack said:
I'm not sure what you've tried, but I would start by using the OnChange event
of the control you want to count the characters in, and updating the counter
from there.

Private Sub Textbox1_Change()
Me.txtCounter = Len(Nz(Me.Textbox1.Text, 0))
End Sub

hth
I have a text box bound to text field I have limited to 155 characters.
That's all the data I want the users to be able to enter. I also have a text
[quoted text clipped - 4 lines]
types in the text. The things I've tried always refresh the whole form so I
can't continually type out a sentence. Is there anyway to accomplish this?
 
J

Jack Leach

oops.... change that... the counter would return 1 if you use the expression
I gave
Private Sub Textbox1_Change()
Me.txtCounter = Len(Nz(Me.Textbox1.Text, 0))
End Sub

should be

Len(Nz(Me.Textbox1.Text, ""))

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top