Label Not Defined

G

Guest

I have been looking through previous links but still fail to find anything to
help with this error. I am getting a label not defined error on the 2nd
line. All the posts I have been reading deal with errors further down the
syntex.


Private Sub rptalphabtn_Click()
On Error GoTo Err_rptalphabtn_Click

Dim stDocName As String

stDocName = "Alpha Roster (By Dept)"
DoCmd.OpenReport stDocName, acPreview

Exit_rptalphabtn_Click:
Exit Sub

Err_rptbirthdaybtn_Click:
MsgBox Err.Description
Resume Exit_rptalphabtn_Click

End Sub
 
G

George Nicholson

On Error GoTo Err_rptalphabtn_Click
......
Err_rptbirthdaybtn_Click:


Err_rptalphabtn_Click doesn't exist but
Err_rptbirthdaybtn_Click does, that's why you get the error.

Change either the label or the GoTo so that they match.

I'd change the label to
Err_rptalphabtn_Click:

HTH
 
G

Guest

The On Error is incorrect

Private Sub rptalphabtn_Click()
' On Error GoTo Err_rptalphabtn_Click - ***** it doesn't exist *****

' Should be
On Error GoTo Err_rptbirthdaybtn_Click

Dim stDocName As String

stDocName = "Alpha Roster (By Dept)"
DoCmd.OpenReport stDocName, acPreview

Exit_rptalphabtn_Click:
Exit Sub

Err_rptbirthdaybtn_Click:
MsgBox Err.Description
Resume Exit_rptalphabtn_Click

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

Similar Threads


Top