Form_Timer() does not work...

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
 
M

mikey014

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
 

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

Similar Threads


Top