Counting characters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I've got a text field that can accept 255 characters. I'm using text
because I want the field to behave in queries. I would like users to see a
countdown of characters as they are keyed in i.e. str=255-Len([Description])
& " Chars left"

I can get the counter working with OnKeyDown and OnKeyPress events but only
after the field is updated and the focus is moved. How can I get the
calculation to perform each time a character is added to the field ?

TIA
 
To get the un-committed value, you need to refer to the Text property of the
control, instead of the default Value property. You can only refer to the
Text property of an Access form control when the control has focus
(otherwise you'll raise an error) but that shouldn't be a problem in the
KeyDown, KeyPress, or Change events of the control ...

Private Sub TestText_Change()

Me.Label6.Caption = Len(Me.TestText.Text)

End Sub
 
Many thanks ...

Brendan Reynolds said:
To get the un-committed value, you need to refer to the Text property of the
control, instead of the default Value property. You can only refer to the
Text property of an Access form control when the control has focus
(otherwise you'll raise an error) but that shouldn't be a problem in the
KeyDown, KeyPress, or Change events of the control ...

Private Sub TestText_Change()

Me.Label6.Caption = Len(Me.TestText.Text)

End Sub

--
Brendan Reynolds

SimonW said:
Hi, I've got a text field that can accept 255 characters. I'm using text
because I want the field to behave in queries. I would like users to see
a
countdown of characters as they are keyed in i.e.
str=255-Len([Description])
& " Chars left"

I can get the counter working with OnKeyDown and OnKeyPress events but
only
after the field is updated and the focus is moved. How can I get the
calculation to perform each time a character is added to the field ?

TIA
 
Works well, thanks

Brendan Reynolds said:
To get the un-committed value, you need to refer to the Text property of the
control, instead of the default Value property. You can only refer to the
Text property of an Access form control when the control has focus
(otherwise you'll raise an error) but that shouldn't be a problem in the
KeyDown, KeyPress, or Change events of the control ...

Private Sub TestText_Change()

Me.Label6.Caption = Len(Me.TestText.Text)

End Sub

--
Brendan Reynolds

SimonW said:
Hi, I've got a text field that can accept 255 characters. I'm using text
because I want the field to behave in queries. I would like users to see
a
countdown of characters as they are keyed in i.e.
str=255-Len([Description])
& " Chars left"

I can get the counter working with OnKeyDown and OnKeyPress events but
only
after the field is updated and the focus is moved. How can I get the
calculation to perform each time a character is added to the field ?

TIA
 
Back
Top