Limit number of characters in a text box

X

XP

Using Office 2003 on Windows XP;

I have an unbound text box on a tab control that at the moment is allowing a
very large amount of text to be entered.

How can I limit the number of characters allowed to be entered into this
text box to 255?

Thanks for your help.
 
K

kingston via AccessMonster.com

Try using the text box's validation rule with something like:

Len([TextBoxName])<256
 
M

Marshall Barton

XP said:
Using Office 2003 on Windows XP;

I have an unbound text box on a tab control that at the moment is allowing a
very large amount of text to be entered.

How can I limit the number of characters allowed to be entered into this
text box to 255?


If a text box is bound to a Text field, you will not be able
to enter more characters than the field's Field Length
allows.

If the text box is bound to a Memo field, then I have to ask
why you are using a Memo field?

If the text box is unbound (or a memo field), then use the
text box's Change event to check fo too many characters.

If Len(Me.textbox.Text) > 255 Then
Me.textbox.Text = Left(Me.textbox.Text,255)
Beep
End If
 
X

XP

The text box is unbound.

The field is not a memo, but a regular text field (max 255); but, I have to
ask:

Are memo fields not recommended?
Does using memo fields lead to unstable DBs?

Please fill me in. Thanks.
 
M

Marshall Barton

Did the code do what you want?

If the text box is unbound, what field are you talking
about?

My point about a memo field was that it's a waste of
resources if you are only going to use 255 characters.

Memo field can be so large (64K ia bound text box, 1GB via
VBA), that they are saved in a separate area from the
record's normal fields. This makes them susceptable to a
type of corruption that normal fields can not encounter. I
have only seen it rarely when two users are updating the
same record at the same time.
 
X

XP

Yes, I used your suggestion for the unbound text box and it worked.
It updates a text column in a table; so no problem.

Good to know about the memo field, I do have a couple in the DB, but it is
unavoidable based on the info they store.

Thanks again.

Marshall Barton said:
Did the code do what you want?

If the text box is unbound, what field are you talking
about?

My point about a memo field was that it's a waste of
resources if you are only going to use 255 characters.

Memo field can be so large (64K ia bound text box, 1GB via
VBA), that they are saved in a separate area from the
record's normal fields. This makes them susceptable to a
type of corruption that normal fields can not encounter. I
have only seen it rarely when two users are updating the
same record at the same time.
--
Marsh
MVP [MS Access]

The text box is unbound.

The field is not a memo, but a regular text field (max 255); but, I have to
ask:

Are memo fields not recommended?
Does using memo fields lead to unstable DBs?
 

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

Top