A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Form_Timer() does not work...



 
 
Thread Tools Display Modes
  #1  
Old July 17th, 2008, 07:29 PM posted to microsoft.public.access.forms
mikey014
external usenet poster
 
Posts: 4
Default Form_Timer() does not work...

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

  #2  
Old July 17th, 2008, 08:07 PM posted to microsoft.public.access.forms
boblarson[_2_]
external usenet poster
 
Posts: 12
Default Form_Timer() does not work...

Don't use the timer. Just use

=Len(Me.YourTextBoxName.Text)

in the On Change event of the textbox

--

Bob Larson
Access MVP
Access World Forums Administrator
Utter Access VIP
Free Access Resources at http://www.btabdevelopment.com


"mikey014" wrote in message
...
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



  #3  
Old July 17th, 2008, 08:13 PM posted to microsoft.public.access.forms
mikey014
external usenet poster
 
Posts: 4
Default Form_Timer() does not work...

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


"boblarson" wrote:

Don't use the timer. Just use

=Len(Me.YourTextBoxName.Text)

in the On Change event of the textbox

--

Bob Larson
Access MVP
Access World Forums Administrator
Utter Access VIP
Free Access Resources at http://www.btabdevelopment.com


"mikey014" wrote in message
...
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




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.