Counting characters in text box

ubgu3

Registered User.
Local time
Tomorrow, 07:55
Joined
Nov 21, 2006
Messages
13
Wise one, I have looked for this throughout the forum but could not fiend an answer. Could you help? I have found a little script to display the number of characters entered into a text box so at to warn the user if they are getting close to the maximum number of characters allowed.
See http://www.databasedev.co.uk/counting_characters.html
I cannot get it to work. The problem is that I can only enter 1 character. It counts it but then highlights the character I just typed. I then have to click next to it to input the next character. Any Ideas?
Cheers,
Rene
 
Shortened to ... does the same work I think.

Code:
Private Sub Field1_Change()
   Me.txtCharsUsed = Len(Nz(Me.Field1.Text, "")) & " characters used in this review."
End Sub

Private Sub Form_Current()
   Me.Field1.SetFocus
   Field1_Change
End Sub
 
Flicker problem

It never stops amazing me what you guys know, which unfortunately highlights what I don’t! Both scripts work OK but I encounter a “flicker” every time I enter a character. My text box is housed within a tab control. Could this be the problem?
Cheers,
Rene
 
Solved but additional question

Disregard last. I have put the output at the top of the page outside the tab control and this works fine. I use it for several text boxes so I ended up using this code in all the boxes I need the counter to work on:

Private Sub txtTheBox_Change()
Me.txtCharsUser = Len(Nz(Me.txtTheBox.Text, "")) & " / 255 used"
End Sub


I have not used the second part of your code because it works well without it:

Private Sub Form_Current()
Me.Field1.SetFocus
Field1_Change
End Sub


Will this cause a problem?

Just one more question. In the code above, could I replace the 255 text & " / 255 used" to the maximum allowable characters as dictated in the table's data type field size entry.

In other words, where the field size is set to 255 characters the code will display X / 255 used and where the field size is set to 50 characters the code will display X / 50 used.

I must say that your assistance is tremendously appreciated. I’m learning a lot!

Rene
 

Users who are viewing this thread

Back
Top Bottom