Hi everyone.
I am trying to put error handling in a before update event I'm using on a subform (subfrmProgramLeadership)with the following and receive a syntax error on the first line. Haven't seen this before. Appreciate any guidance. Thank you! - Scott
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo subform_BeforeUpdate_Err
Dim strCriteria As String
strCriteria = " ResourceID=" & Me.ResourceID & " AND ProgramID=" & Me.ProgramID
If DCount("ResourceID ", "tblProgramLeadership", strCriteria) > 0 Then
MsgBox "This resource is already on the leadership team", vbInformation, "Duplicate Resource Alert"
Cancel = True
Me.Undo
End If
GoTo subform_BeforeUpdate_Exit:
Exit Sub
GoTo subform_BeforeUpdate_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume GoTo subform_BeforeUpdate_Exit
End Sub
Error handling syntax issue
-
- Administrator
- Posts: 78586
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Error handling syntax issue
The label names are incorrect; they should not contain the word GoTo:
GoTo subform_BeforeUpdate_Exit:
should be
subform_BeforeUpdate_Exit:
and
GoTo subform_BeforeUpdate_Err:
should be
GoTo subform_BeforeUpdate_Err:
Finally, there shouldn't be a GoTo after Resume:
Resume subform_BeforeUpdate_Exit
GoTo subform_BeforeUpdate_Exit:
should be
subform_BeforeUpdate_Exit:
and
GoTo subform_BeforeUpdate_Err:
should be
GoTo subform_BeforeUpdate_Err:
Finally, there shouldn't be a GoTo after Resume:
Resume subform_BeforeUpdate_Exit
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 402
- Joined: 14 Apr 2010, 15:59
Re: Error handling syntax issue
Thank you Hans.