Require Field if another field is not blank

  • Thread starter Thread starter OsmoseTom
  • Start date Start date
O

OsmoseTom

I am having some troble with my code within a form. What I am trying to do
is diplay a message box and require entry for a field when another field has
an amount greater than zero.

Here is my code that is not working.


Private Sub Sun_Hours_1_Exit(Cancel As Integer)

Dim strMsg As String
If (Me.[Sun PR OUS 1] = "" And Me.[Sunday Hours 1] > 0) Then
Beep
MsgBox "If hours are entered for sunday a corresponding PR OUS job number is
required.", vbOKOnly, "Entry Required"
Cancel = True
End If

End Sub

Can someone please help me?
 
OsmoseTom said:
I am having some troble with my code within a form. What I am trying to do
is diplay a message box and require entry for a field when another field has
an amount greater than zero.

Here is my code that is not working.


Private Sub Sun_Hours_1_Exit(Cancel As Integer)

Dim strMsg As String
If (Me.[Sun PR OUS 1] = "" And Me.[Sunday Hours 1] > 0) Then
Beep
MsgBox "If hours are entered for sunday a corresponding PR OUS job number is
required.", vbOKOnly, "Entry Required"
Cancel = True
End If

End Sub

Can someone please help me?

Try this:

If (IsNull(Me.[Sun PR OUS 1]) And Me.[Sunday Hours 1] > 0) Then

Tom Lake
 
Back
Top