G
Guest
I have a subform (frm_OrderDetails) embedded in a form (frm_Main). There are
two fields (Part Number - which is on the subform frm_OrderDetails) and
RQNNumber - which is on the form frm_Main). I am trying to write a statement
that states 1) if the field Part Number is blank, the user may exit via the
cmd_Close button to the previous form or 2) if the field RQNNumber is blank
and the field Part Number is blank, the user may exit via the command button.
However, if there is data on the form in the Part Number field, then there
must be data in the RQNNumber field. Any help on this is greatly
appreciated. Here is what I have so far:
Private Sub cmd_close_Click()
On Error GoTo Err_cmd_close_Click
If [Forms]![frm_Main]![frm_OrderDetails]![PartNumber] Is Blank Then
DoCmd.Close
Else
If [Forms]![frm_Main]![RQNNumber] = "0" Then
MsgBox ("Requisition Number is a required field. You cannot leave it blank.")
Else
DoCmd.Close
Exit_cmd_close_Click:
Exit Sub
Err_cmd_close_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmd_close_Click
End If
End If
End Sub
two fields (Part Number - which is on the subform frm_OrderDetails) and
RQNNumber - which is on the form frm_Main). I am trying to write a statement
that states 1) if the field Part Number is blank, the user may exit via the
cmd_Close button to the previous form or 2) if the field RQNNumber is blank
and the field Part Number is blank, the user may exit via the command button.
However, if there is data on the form in the Part Number field, then there
must be data in the RQNNumber field. Any help on this is greatly
appreciated. Here is what I have so far:
Private Sub cmd_close_Click()
On Error GoTo Err_cmd_close_Click
If [Forms]![frm_Main]![frm_OrderDetails]![PartNumber] Is Blank Then
DoCmd.Close
Else
If [Forms]![frm_Main]![RQNNumber] = "0" Then
MsgBox ("Requisition Number is a required field. You cannot leave it blank.")
Else
DoCmd.Close
Exit_cmd_close_Click:
Exit Sub
Err_cmd_close_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmd_close_Click
End If
End If
End Sub