Size of a text field - how to block it?

Leen

Registered User.
Local time
Today, 17:18
Joined
Mar 15, 2007
Messages
56
Hi,

I have created a table using vba. To create the fields I used the folowing statement:
.Fields.Append .CreateField("SNAM1LC", dbText, 3)

In this case the fieldlength is maximum 3. However, I'd like to force in some way that that field can only have inputs of exactly 3 characters. So that during input no mistakes can be typed by typing for example only 2 characters.

Is there a way to integrate this into the table-definition? To "block" the length of a text field?

Thanks a lot on forehand!
Leen
 
if the max length is 3 characters then thats all you can enter. look up input mask in help.
 
HI,

When I look to the help about InputMask, this property applies only on combobox and textbox.
However, I want the restriction that when entering data in a TABLE, the fieldlenght entered should be EXACTLY 3 (Not maximum 3). So I think it should be one of the properties of a field, but I don't know how to apply this.

It tried via:
Code:
tbl.Fields!SNAM1LC.ValidationRule = "LEN(SNAM1LC) = 3"
tbl.Fields!SNAM1LC.ValidationText = "Length of the languagecode must be equal to 3"
tbl.Fields!SNAM1LC.ValidateOnSet = True

But this doesn't work. My goal is that, in the model of the table, in the field SNAM1LC only data can be entered having 3 characters.

Some idea how to achieve this?
Thanks a lot on forehand,
Leen
 
Data should only be entered via a form. However you can use an input mask to ensure that 3 characters are always entered. open your table in table design mode, position your cursor in the input mask field and press f1 to look up the examples for text.
 
Try with brackets

"LEN([SNAM1LC]) = 3"

Alternatively, if it doesn't work, add it to the tabledef validation rule property.

> Data should only be entered via a form.

Sometimes it might come from an import file, from Excel, Word, VB, VBScript or other sources that are not Access forms, in which case engine level validation might be necessary to ensure data integrity.
 
Thanks!!

With the brackets it works!

Leen
 

Users who are viewing this thread

Back
Top Bottom