Combine two cmd buttons onto one

S

Sandy

I have two buttons on my form running these two macros

"Private Sub cmdPrint_Job_Sheet_Click()
On Error GoTo Err_cmdPrint_Job_Sheet_Click

Dim stDocNameCustomer, stDocNameWorkshop As String

stDocNameCustomer = "rpt_Single_Record_Customer"
DoCmd.OpenReport stDocNameCustomer, acNormal

stDocNameWorkshop = "rpt_Single_Record_Workshop"
DoCmd.OpenReport stDocNameWorkshop, acNormal

Exit_cmdPrint_Job_Sheet_Click:
Exit Sub

Err_cmdPrint_Job_Sheet_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Job_Sheet_Click

End Sub"

"Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click

DoCmd.Close

Exit_CloseForm_Click:
Exit Sub

Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click

End Sub"

I would like to combine them onto one button but I can't get my head round
the Error and Exit sub parts of it and where they should all be positioned.

Guidance would be very welcome.
Sandy
 
R

Rick Brandt

Sandy said:
I have two buttons on my form running these two macros

"Private Sub cmdPrint_Job_Sheet_Click()
On Error GoTo Err_cmdPrint_Job_Sheet_Click

Dim stDocNameCustomer, stDocNameWorkshop As String

stDocNameCustomer = "rpt_Single_Record_Customer"
DoCmd.OpenReport stDocNameCustomer, acNormal

stDocNameWorkshop = "rpt_Single_Record_Workshop"
DoCmd.OpenReport stDocNameWorkshop, acNormal

Exit_cmdPrint_Job_Sheet_Click:
Exit Sub

Err_cmdPrint_Job_Sheet_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Job_Sheet_Click

End Sub"

"Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click

DoCmd.Close

Exit_CloseForm_Click:
Exit Sub

Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click

End Sub"

I would like to combine them onto one button but I can't get my head
round the Error and Exit sub parts of it and where they should all be
positioned.
Guidance would be very welcome.
Sandy

(unnecessary verbosity removed)

Private Sub cmdPrint_Job_Sheet_Click()

On Error GoTo Err_cmdPrint_Job_Sheet_Click

DoCmd.OpenReport "rpt_Single_Record_Customer", acNormal
DoCmd.OpenReport "rpt_Single_Record_Workshop", acNormal
DoCmd.Close

Exit_cmdPrint_Job_Sheet_Click:
Exit Sub

Err_cmdPrint_Job_Sheet_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Job_Sheet_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

Top