J
Jody
I have a form that I have been requested to make certian fields required on.
However, they only need to be required if there is a value in a corresponding
field. There are 20 potential "required" fields on this form. I have the
following code which works for one required field, but I am having trouble
with joining multiple statements together to get the desired effect on all 20
fields:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me.PITM1) > 0 And IsNull(Me.PQTY1) Then
MsgBox "QTY is required"
Cancel = True
Me.PQTY1.SetFocus
End If
Else
If (Me.CITM1) > 0 And IsNull(Me.CQTY1) Then
MsgBox "QTY is required"
Cancel = True
Me.CQTY1.SetFocus
End If
End Sub
I am getting a compile error: "Else without If" when this code trys to run.
Can someone point me in the right direction?
However, they only need to be required if there is a value in a corresponding
field. There are 20 potential "required" fields on this form. I have the
following code which works for one required field, but I am having trouble
with joining multiple statements together to get the desired effect on all 20
fields:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me.PITM1) > 0 And IsNull(Me.PQTY1) Then
MsgBox "QTY is required"
Cancel = True
Me.PQTY1.SetFocus
End If
Else
If (Me.CITM1) > 0 And IsNull(Me.CQTY1) Then
MsgBox "QTY is required"
Cancel = True
Me.CQTY1.SetFocus
End If
End Sub
I am getting a compile error: "Else without If" when this code trys to run.
Can someone point me in the right direction?