Object Required error

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
 
G

Guest

Try changing to:
Private Sub cmd_close_Click()
On Error GoTo Err_cmd_close_Click
If isnull([Forms]![frm_Main]![frm_OrderDetails]![PartNumber]) 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
End If
End If

Exit_cmd_close_Click:
Exit Sub


Err_cmd_close_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmd_close_Click

End Sub
 
G

gaoke

schasteen said:
Try changing to:
Private Sub cmd_close_Click()
On Error GoTo Err_cmd_close_Click
If isnull([Forms]![frm_Main]![frm_OrderDetails]![PartNumber]) 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
End If
End If

Exit_cmd_close_Click:
Exit Sub


Err_cmd_close_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmd_close_Click

End Sub

Mr. Smiley said:
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
 
G

gaoke

schasteen said:
Try changing to:
Private Sub cmd_close_Click()
On Error GoTo Err_cmd_close_Click
If isnull([Forms]![frm_Main]![frm_OrderDetails]![PartNumber]) 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
End If
End If

Exit_cmd_close_Click:
Exit Sub


Err_cmd_close_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmd_close_Click

End Sub

Mr. Smiley said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top