validation rule

  • Thread starter Thread starter Chuck216
  • Start date Start date
C

Chuck216

Hi

I would like to place a validation rule on a form and can not figure out the
code.

What I want to do is:

If Me.wait8-9 >14 then
Me.hour8-9 must be >0

Thanks in advance for any help with this

Chuck
 
Hi

I would like to place a validation rule on a form and can not figure out the
code.

What I want to do is:

If Me.wait8-9 >14 then
Me.hour8-9 must be >0

Thanks in advance for any help with this

Chuck

I'd do this kind of validation in the Form's BeforeUpdate() event - this has a
Cancel operand, set it to True to block the update:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me![wait8-9] >14 Then
If NZ(Me![hour8-9]) = 0 Then
Cancel = True
MsgBox "You must fill in Hour8-9", vbOKOnly
Me![hour8-9].SetFocus
End If
End If
End Sub

I must say that these control names - especially if the correspond to
fieldnames - are worrisome; it looks like you're storing data in fieldnames,
never a good idea.
 
Thank you that works great!



John W. Vinson said:
Hi

I would like to place a validation rule on a form and can not figure out the
code.

What I want to do is:

If Me.wait8-9 >14 then
Me.hour8-9 must be >0

Thanks in advance for any help with this

Chuck

I'd do this kind of validation in the Form's BeforeUpdate() event - this has a
Cancel operand, set it to True to block the update:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me![wait8-9] >14 Then
If NZ(Me![hour8-9]) = 0 Then
Cancel = True
MsgBox "You must fill in Hour8-9", vbOKOnly
Me![hour8-9].SetFocus
End If
End If
End Sub

I must say that these control names - especially if the correspond to
fieldnames - are worrisome; it looks like you're storing data in fieldnames,
never a good idea.
 
Back
Top