Minimum number of entries

E

Erik_norway

Hi,

Is there a way to restrict the numbers of entries in a text field to a minimum, ex 9 entries as text ("a", "b" etc... max nine) and a maximum of 9`

Erik
 
A

Alex Dybenko

not quite understand what restriction you mean, but you can do almost
everything if you can write expression to validate entry. expression you can
put either in validation property of table (simple) or in beforeupdate event
of textbox on a form
HTH
--
Alex Dybenko (MVP)
http://Alex.Dybenko.com


Erik_norway said:
Hi,

Is there a way to restrict the numbers of entries in a text field to a
minimum, ex 9 entries as text ("a", "b" etc... max nine) and a maximum of
9`?
 
E

Erik_norway

Hi,

the restriction im looking for is for a text field that should be maximum 9 charachters and at the same time no less. Example when the user writes 12345678 but leaves the 9 blank there should be a message asking the user to enter the last charachter.

Erik
 
J

Jim Allensworth

Hi,

the restriction im looking for is for a text field that should be maximum 9 charachters and at the same time no less. Example when the user writes 12345678 but leaves the 9 blank there should be a message asking the user to enter the last charachter.

Erik

Just test for length in the BeforeUpdate event of the text box.

Private Sub txtMyTextBox
Private Sub txtMyTextBox_BeforeUpdate(Cancel As Integer)
If Len(Me.txtMyTextBox & "") <> 9 Then
MsgBox "Nine characters are required for entry."
Cancel = True
End If
End Sub

- Jim
 
T

Tim Ferguson

the restriction im looking for is for a text field that should be
maximum 9 charachters and at the same time no less.

1) Protect the table with a ValidationRule like

Len(MyField)=9

or, if you don't provide a DefaultValue, then

Is Null Or Len(MyField)=9

2) Protect the user by catching the BeforeUpdate event of the control on
every form that is bound to the field, and doing something intelligent with
it -- either a message, or mending the value, or looking it up in the
MasterTable or whatever.

Hope that helps


Tim F
 

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