Count Characters Entered on an Unbound Textbox

B

Bob Barnes

How??

This won't work...
Private Sub DESCRIPTION_Change()
If Not IsNull(DESCRIPTION) Then
MsgBox Len(DESCRIPTION)
Else
MsgBox "AAA" --> always get this on the unbound textbox
End If
End Sub

TIA - Bob
 
W

Wayne-I-M

Hi

If it were me I would simplify the whole the thing.

This should start you off

Create a new form
Create 2 text boxes - txtInput and txtCount

add this the after update of txtInput

Private Sub txtInput_AfterUpdate()
Me.txtCount = Len(txtInput)
End Sub

This will give you a count of the items you have typed into txtInput

Next add the if len = 0 then stuff.... with a message if you need

Next - search the help file on the Len Function

Good luck
 
B

Bob Barnes

Wayne - WORKS great. Thank you - Bob

Wayne-I-M said:
Hi

If it were me I would simplify the whole the thing.

This should start you off

Create a new form
Create 2 text boxes - txtInput and txtCount

add this the after update of txtInput

Private Sub txtInput_AfterUpdate()
Me.txtCount = Len(txtInput)
End Sub

This will give you a count of the items you have typed into txtInput

Next add the if len = 0 then stuff.... with a message if you need

Next - search the help file on the Len Function

Good luck
 
B

Bob Barnes

This works if an Enter/Tab (causes AfterUpdate)..but
doesn't as characters are typed in.

Any way to "record" the number of characters typed in
before Updating or Exiting the unbound textbox???

TIA - Bob
 
W

Wayne-I-M

Yes - but don't do it. You can use the keypress event but you would need to
refresh and do all sorts of other mad stuff to get it to work and the Ascii
property would mess this up a little anyway. Te form will become overworked
very quicky

Just use the afterupdate - this sort be Ok
 
B

Bob Barnes

Please tell me more. The User doesn't want to AfterUpdate. In VB6, I think
there's a MaxLength property..anything similar in Access VBA?

This will be restricted to one Field in a very small Form.

Thank you - Bob
 
A

Albert D. Kallal

In the text boxes on-change event, simple go:


me.txtBoxToShowLength = len(me.MyTextBox.text)


So, you can do the whole thing for ONE line of code....

note the use of the .text property in the above. "text" is the status/value
of the text box BEFORE you hit tab.....
 
Top