Compile Error: label not defined

W

Walter

I have a form to enter service records for equipment.
There is a control for TruckID , one for TrailerID, and
one for Odometer. If a truck number is entered, I want to
disable the TrailerID and go to the Odometer control. I
put the following code in the AfterUpdate event of the
TruckID control.
Private Sub TruckID_AfterUpdate()
On Error GoTo Err_TruckID_AfterUpdate
'disables TrailerID and sets focus to Odometer
If IsNull(TruckID) = True Then
TrailerID.Enabled = True
Else
TrailerID.Enabled = False
Odometer.SetFocus
End If

Err_TruckID_AfterUpdate:
MsgBox Err.Description
Resume Exit_TruckID_AfterUpdate


End Sub

When I enter a truck number, I get the Error Msg: Compile
Error Label not defined. The Private Sub
TuckID_AfterUpdate() line is highlighted in yellow and the
Resume Exit_TruckID_AfterUpdate line is highlighted in
blue. I have looked at other sub routines and don't see
anything different about the way I have this written. Can
anyone tell me what is wrong?

Thanks a bunch,
Walter
 
G

George Nicholson

Walter:

You are missing the 1st 2 lines below: you don't have an "Exit" label, even
though your Err handler refers to it.

Exit_TruckID_AfterUpdate:
Exit Sub
Err_TruckID_AfterUpdate:
MsgBox Err.Description
Resume Exit_TruckID_AfterUpdate
End Sub


BTW, with the Exit:/ExitSub missing, your Err handler code would run every
time this procedure is run, error or not (if you commented out the line with
the reference to the missing label and got it to compile). The code would
run straight through until it encounters the EndSub, so the messagebox would
always be executed.
 
G

Guest

-----Original Message-----
Thanks again for you're help. It works. Walter

Walter:

You are missing the 1st 2 lines below: you don't have an "Exit" label, even
though your Err handler refers to it.

Exit_TruckID_AfterUpdate:
Exit Sub
Err_TruckID_AfterUpdate:
MsgBox Err.Description
Resume Exit_TruckID_AfterUpdate
End Sub


BTW, with the Exit:/ExitSub missing, your Err handler code would run every
time this procedure is run, error or not (if you commented out the line with
the reference to the missing label and got it to compile). The code would
run straight through until it encounters the EndSub, so the messagebox would
always be executed.

--
George Nicholson

Remove 'Junk' from return address.





.
 

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

Similar Threads


Top