Error Coding

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Hi I have lots of code without any error trapping what is the correct way to
trap errors in for example the following code? Also are there any
programmes out there that can put the code in for me?

Private Sub txtExcessApply_AfterUpdate()

If Me.EMExcessPayer = "Employer" Then
Me.EmployerExcess = [ExcessDue] * [txtExcessApply]
Else
If Me.EMExcessPayer = "Driver" Then
Me.DriverExcess = [ExcessDue] * [txtExcessApply]
End If
End If
Me.txtExcessApply.SetFocus

End Sub

Thanks Bob
 
Private Sub txtExcessApply_AfterUpdate()
On Error GoTo Err_txtExcessApply_AfterUpdate

If Me.EMExcessPayer = "Employer" Then
Me.EmployerExcess = [ExcessDue] * [txtExcessApply]
Else
If Me.EMExcessPayer = "Driver" Then
Me.DriverExcess = [ExcessDue] * [txtExcessApply]
End If
End If

Me.txtExcessApply.SetFocus

End_txtExcessApply_AfterUpdate:
Exit Sub

Err_txtExcessApply_AfterUpdate:
MsgBox Err.Number & ": " & Err.Description & _
" occurred in txtExcessApply_AfterUpdate"
Resume End_txtExcessApply_AfterUpdate

End Sub

To automate the inclusion, take a look at MZ Tools http://www.mztools.com/
The VBA version is free.
 
Douglas thanks again for your help.

Bob
Douglas J Steele said:
Private Sub txtExcessApply_AfterUpdate()
On Error GoTo Err_txtExcessApply_AfterUpdate

If Me.EMExcessPayer = "Employer" Then
Me.EmployerExcess = [ExcessDue] * [txtExcessApply]
Else
If Me.EMExcessPayer = "Driver" Then
Me.DriverExcess = [ExcessDue] * [txtExcessApply]
End If
End If

Me.txtExcessApply.SetFocus

End_txtExcessApply_AfterUpdate:
Exit Sub

Err_txtExcessApply_AfterUpdate:
MsgBox Err.Number & ": " & Err.Description & _
" occurred in txtExcessApply_AfterUpdate"
Resume End_txtExcessApply_AfterUpdate

End Sub

To automate the inclusion, take a look at MZ Tools http://www.mztools.com/
The VBA version is free.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bob said:
Hi I have lots of code without any error trapping what is the correct way to
trap errors in for example the following code? Also are there any
programmes out there that can put the code in for me?

Private Sub txtExcessApply_AfterUpdate()

If Me.EMExcessPayer = "Employer" Then
Me.EmployerExcess = [ExcessDue] * [txtExcessApply]
Else
If Me.EMExcessPayer = "Driver" Then
Me.DriverExcess = [ExcessDue] * [txtExcessApply]
End If
End If
Me.txtExcessApply.SetFocus

End Sub

Thanks Bob
 
Back
Top