Validation in text

N

Nick

I am using a text field named "payperiod" in a subform . I want to restrict
data being entered between 1 and 26. I have tried text validation rule 1 or
<27 but I am still able to enter any number in that field. Any sugestions to
correct the problem are appreciated.
 
S

Steve Sanford

Hi Nick,

Just for clarity: tables have fields, forms have controls; controls can be
bound to fields.

So it sounds like you have a text box (control) on a form. If you entered

1 Or < 27

in the validation rule property of the text box, you can enter any number
that is less than 27 (like -100).

If you want to limit the entries to 1 to 26 inclusive, use
0 and < 27

in the validation rule property.


HTH
 
K

Klatuu

In the Before Update event of the control (not a field) payperiod:

Private Sub payperiod_BeforeUpdate(Cancel As Integer)

If Me.payperiod < 1 Or Me.payperiod > 26 Then
MsgBox "Pay Period must be between 1 and 26"
Cancel = True
End If
 
N

Nick

Thanks, works great.

Steve Sanford said:
Hi Nick,

Just for clarity: tables have fields, forms have controls; controls can be
bound to fields.

So it sounds like you have a text box (control) on a form. If you entered

1 Or < 27

in the validation rule property of the text box, you can enter any number
that is less than 27 (like -100).

If you want to limit the entries to 1 to 26 inclusive, use


in the validation rule property.


HTH
 
Top