Form_Timer() does not work...

  • Thread starter Thread starter mikey014
  • Start date Start date
M

mikey014

Hi,

I am trying to display the number of characters left in a text box since
I want to limit the length of the string to 1000 characters. I thought that
if I set the TimerInterval to 1000, and then the OnTimer event to check the
lenght of the string in the text box, that I could display the remaining
characters.

The problem is that the OnTimer event only fires once, and then will not
update again until I change records and then come back. Am I missing
something basic here?

Sub Form_Load()
Me.TimerInterval = 1000
End Sub

Sub Form_Timer()

Dim iLeft As Integer

If IsNull(Me.SampleText) Or Me.SampleText = "" Then
iLeft = 1000
Else
iLeft = 1000 - Len(Me.SampleText)
End If

Me.txtCount = "Characters Left: " & iLeft

End Sub
 
That worked perfectly! Here is the code as written:

Private Sub SampleText_Change()

Dim iLeft As Integer

iLeft = 1000 - Len(Me.SampleText.Text)
Me.txtCount = "Characters left: " & iLeft

End Sub
 
Back
Top