M
macroapa
Hi, I have a userform with an unbound textbox where the contents will
ultimately be sent to a memo field in a table.
Now I want to limit the textbox length to 500 characters. I've
happily got code to check/validate this before it is sent to the
table, but this is a bit after the fact for the user.
What i want is a label underneath the text box which dynamically
updates as the user is typing into the textbox to show how many
characters they have left.
Now i thought this would be easy as i'd just use the on key press
event and test the length of the textbox and update the label
accordingly. However, it seems the value of the textbox in code
remains as null until you have exited the textbox.
I have used a bodged workaround whereby i have a public variable which
is initiated as 0 and is incremented by 1 in the on key press event.
Whilst this works well to a degree, it doesn't cater for situations
where the user deletes text. Now I know i could write some code to
test if the keypress was a backspace or delete key and if so decrement
my variable by one, but this still won't cater for situations where
the user highlights bulk text and presses delete.
Has anyone got any suggestions?
Thanks.
ultimately be sent to a memo field in a table.
Now I want to limit the textbox length to 500 characters. I've
happily got code to check/validate this before it is sent to the
table, but this is a bit after the fact for the user.
What i want is a label underneath the text box which dynamically
updates as the user is typing into the textbox to show how many
characters they have left.
Now i thought this would be easy as i'd just use the on key press
event and test the length of the textbox and update the label
accordingly. However, it seems the value of the textbox in code
remains as null until you have exited the textbox.
I have used a bodged workaround whereby i have a public variable which
is initiated as 0 and is incremented by 1 in the on key press event.
Whilst this works well to a degree, it doesn't cater for situations
where the user deletes text. Now I know i could write some code to
test if the keypress was a backspace or delete key and if so decrement
my variable by one, but this still won't cater for situations where
the user highlights bulk text and presses delete.
Has anyone got any suggestions?
Thanks.