Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit To Chars In Text Box?

Status
Not open for further replies.

rookery

Programmer
Apr 4, 2002
384
0
0
GB
I know this may be a trifle simplistic but is it possible to limit the number of characters entered into an Unbound Text Box in Access2k?

I know that if it was bound to a field I could set the value of the field etc etc.

Any ideas?
 
You can use the validation rule within the properties section of the text field.

For example
Entering ???? would limit the input to the field to 4 characters
 
You can use the validation rule within the properties section of the text box.

For example
Entering ???? would limit the input to the text box to 4 characters
 
Thanks for replying Lad but I'm afraid your suggestion doesnt seem to work. I get an error message saying that i've entered invalid syntax. I tried putting it into Validation Text instead to no avail.

Any other ideas?
 
Try

like "????"

Remember that you can now type information into the validation text section
 
I tried enclosing the question marks in quotes but this didnt seem to work either. I think i'm gonna have to link the fields to a table. Thanks anyway.... unless you have anymore ideas....?
 
Did you enter the complete line
You must enter the like part as well!!!!!!!!!

The complete line in the validation text must be

like "????"
 
Yes I did. It actually puts it in there automatically once you move focus. Strange one this. Cant find any other similar threads either.
 
What error message are you getting after you tab out of the validation rule part

[surprise]
 
I have left this blank so far. What should I put in there? Is this where its falling down?
 
Just to confirm that we are both talking about the same thing

1) You are in the design view of a form
2) You have an unbound text box in this form.
3) Select the properties of the text box
4) Select the data tab
5) In the validation rule section type the following

Like "????"

6) Tab out of this section.
7) Type a message into the Validation Text Part
8) Leave design view and go to form view
9) Now test the text box by entering 5 characters and hitting enter as if to leave the text box.
10) The message typed in the Validation Text part should come up.

Note that the amount of question marks controls the amount of characters you can enter

[pipe]
 
Wahay we seem to be getting somewhere! Ideally I would have liked it so that you couldnt physically type more than 4 chars into the box in the 1st place (rather than getting an error message when you tab out of it) but this is still a good fix.

Thanks for all your help on this matter.
 
This should have been done using the input mask property....

CCCC allows up to 4 characters to be entered and no more.

&&&& allows exactly 4 characters to be entered.

Craig
 
Can you not just put the ???? in the input mask .. that way you will get no error messages and can only type in exactly that number of chars.
 
As a follow-up I stumbled across the solution to this problem today (I haven't been sweating over it since July!).

All you need to do is put:

????;;" "

in the Input Mask and the space after the '?'s eliminates the annoying underscore that is usually there when you enter the text box. Easy when you know how!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top