Darren DICK
d.dick at uws.edu.au
Tue Dec 2 21:39:03 CST 2003
Hello all I need to see if the number of characters typed in to a field matches a pre determined number...say...10. (Data type is irrelevant. Just need to count whatever they type) Using the Len() function I can count the number of characters in a text box. No prob. But only after leaving the text box I assume 'coz Access doesn't update the contents of the control or 'accept' the newly added contents of a control until you leave that control. So.. When I run the sub below in the on Change of a text box it doesn't work 'til after I leave the text box. Does anyone know how to get it to work with each change or addition of a character? (I even had the code going to an unimportant control on the form to force the update on each OnChange then got it to return to my text box. This works fine except when I add a space to the text I am typing the cursor leaves the control then returns and ignores the space so I can't type anything except 1 great big long word) Many thanks in advance Darren eg Private Sub ps_CheckExplanationLength() Dim intCharsSoFar as integer Dim intMinChars as integer intMinChars = 10 ' No of characters typed before enableing apply button intCharsSoFar = Len(Me.txtExplanation) ' Typed so far... If intCharsSoFar > intMinChars Then Me.cmdApply.Enabled = True ' has met the criteria Else Me.cmdApply.Enabled = False 'has not met End If End Sub