Len Textbox

GavZ

Mostly Beginners Luck!
Local time
Today, 11:16
Joined
May 4, 2007
Messages
56
Hi,

I have a textbox called ETxt and i have another called CLeft, both of which are unbound. I want to limit ETxt to 120 characters and let CLeft countdown as you type from 120 showing how many characters you have left to type.

I have tried using the Len function but cant get it to work in the correct way.

Thanks you in advance!!
 
I don't think what you want to do is possible in an Access form, the textbox value won't update until you change focus to another control. I think the best you could do is to set the Len(textbox) <=120 in the Before Update event of the textbox, if the value is too large then you can take the left most 120 characters, or cancel the update, or alert the user, or whatever you want.
 
You will need to look at the Len(Me.ControlName.Text) ".Text" property in the Change event of your Control. Using your control name of course.
 
As RuralGury says. And you'll need to requery the Cleft textbox. So your code in the On Change event will be:

Me.CLeft = 120 - Len(Me.ETxt.Text)
Me.CLeft.Requery

This question gave me an idea to use in my own d/b. Thanks for the tips all.
 
Thanks stopher! Works a treat.

So how do you limit an unbound textbox to 120 chars?
 

Users who are viewing this thread

Back
Top Bottom