Minimum number of entries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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`?
 
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
 
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
 
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
 
Back
Top