This code does not belong
Exit_cmdPrintC5_Click:
Exit Sub
Everything else looks good though
It should probably look like this
Code:
Private Sub CmdPrintDLenv_Click()
On Error GoTo Err_CmdPrintDLenv_Click
Dim stDocName As String
Dim strWhere As String
strWhere = "[MailingListID] = " & Me.MailingListID
stDocName = "print Dl envelop"
DoCmd.OpenReport stDocName, acNormal, , strWhere
Err_CmdPrintDLenv_Click:
MsgBox Err.Description
Resume Exit_CmdPrintDLenv_Click
End Sub
This is the code that is doing the work
Code:
Dim stDocName As String
Dim strWhere As String
strWhere = "[MailingListID] = " & Me.MailingListID
stDocName = "print Dl envelop"
DoCmd.OpenReport stDocName, acNormal, , strWhere
The other code is error handling that is specific to the control's name. So this part of the code is not interchangeable between controls with different names.