Count Characters Entered on an Unbound Textbox

  • Thread starter Thread starter Bob Barnes
  • Start date Start date
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
 
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
 
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
 
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
 
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
 
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
 
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.....
 

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

Back
Top