Multiple Error Trapping for 1 Event

  • Thread starter Thread starter Cabby
  • Start date Start date
C

Cabby

Each of the following 2 lines of code work properly if used
seperately. But when I try to use them together, I get an error.
It has been suggested to use 'Resume Next', but I don't
know where to place it. Can anyone help?

TIA

Cabby

Me.Parent![ctrlSubform2].Requery

OR

Me.Parent!ctrlSubform2.Form!Description.RowSource _
= fProductList(Me!Supplier_ID)

Private Sub Form_Current()
' This code created by Form Wizard.
Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err

Me.Parent![ctrlSubform2].Requery

Me.Parent!ctrlSubform2.Form!Description.RowSource _
= fProductList(Me!Supplier_ID)

End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit
End Sub
 
Cabby said:
Each of the following 2 lines of code work properly if used
seperately. But when I try to use them together, I get an error.
It has been suggested to use 'Resume Next', but I don't
know where to place it. Can anyone help?

TIA

Cabby

Me.Parent![ctrlSubform2].Requery

OR

Me.Parent!ctrlSubform2.Form!Description.RowSource _
= fProductList(Me!Supplier_ID)

Private Sub Form_Current()
' This code created by Form Wizard.
Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err

Me.Parent![ctrlSubform2].Requery

Me.Parent!ctrlSubform2.Form!Description.RowSource _
= fProductList(Me!Supplier_ID)

End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit
End Sub

"Resume Next" will not prevent the error, it will simply cause it to be
ignored.

What error are you getting, and on which line?
 
Baz,
Thanks for the fast reply. As of this moment, I cannot duplicate error
message.
It seems to be working ok. I must have made an incorrect reference to the
subform that I inadvertently cleaned up.

Cabby
Baz said:
Cabby said:
Each of the following 2 lines of code work properly if used
seperately. But when I try to use them together, I get an error.
It has been suggested to use 'Resume Next', but I don't
know where to place it. Can anyone help?

TIA

Cabby

Me.Parent![ctrlSubform2].Requery

OR

Me.Parent!ctrlSubform2.Form!Description.RowSource _
= fProductList(Me!Supplier_ID)

Private Sub Form_Current()
' This code created by Form Wizard.
Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err

Me.Parent![ctrlSubform2].Requery

Me.Parent!ctrlSubform2.Form!Description.RowSource _
= fProductList(Me!Supplier_ID)

End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit
End Sub

"Resume Next" will not prevent the error, it will simply cause it to be
ignored.

What error are you getting, and on which line?
 
Replace the On Error Resume Next with
On Error GoTo Form_Current_Exit

The Resume Next tells VBA to ignore the error
The other other tells VBA to go to the tag in you procedure named
Form_Current_Exit
 

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

Back
Top