Button Coding for Reports

C

channell

Hi, I have 1 button that I need to open two reports. I can get 1 report to
open how I need it, but it refuses to open the second report. I know it is
an issue with my coding, and I am not sure what to do next. It says
something about ambiguous commands, so i am not sure how to combine the two
codes together. Thanks for the help!

Here is my coding:

Private Sub CommandOpen6135r_Click()
On Error GoTo Err_CommandOpen6135r_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "r6135FOREMAIL"

stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

Exit_CommandOpen6135r_Click:
Exit Sub

Err_CommandOpen6135r_Click:
MsgBox Err.Description
Resume Exit_CommandOpen6135r_Click

End Sub


Private Sub CommandOpen6135r_Click()
On Error GoTo Err_CommandOpen6135r_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "r6135EMAIL"

stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

Exit_CommandOpen6135r_Click:
Exit Sub

Err_CommandOpen6135r_Click:
MsgBox Err.Description
Resume Exit_CommandOpen6135r_Click

End Sub
 
M

Marshall Barton

channell said:
Hi, I have 1 button that I need to open two reports. I can get 1 report to
open how I need it, but it refuses to open the second report. I know it is
an issue with my coding, and I am not sure what to do next. It says
something about ambiguous commands, so i am not sure how to combine the two
codes together. Thanks for the help!

Here is my coding:

Private Sub CommandOpen6135r_Click()
On Error GoTo Err_CommandOpen6135r_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "r6135FOREMAIL"

stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria ...
End Sub


Private Sub CommandOpen6135r_Click()
On Error GoTo Err_CommandOpen6135r_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "r6135EMAIL"

stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria ...
End Sub


Combine the two procedures.

For example:

Private Sub CommandOpenBoth_Click()
On Error GoTo Err_Code

Dim stLinkCriteria As String
stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]

DoCmd.OpenReport "r6135FOREMAIL", acViewPreview, ,
stLinkCriteria
DoCmd.OpenReport "r6135EMAIL", acViewPreview, ,
stLinkCriteria

Exit_Command:
DoCmd.Close
Exit Sub

Err_Code:
MsgBox Err.Description
Resume Exit_Command

End Sub
 
C

channell

Perfect! Thank you very much!!

Marshall Barton said:
channell said:
Hi, I have 1 button that I need to open two reports. I can get 1 report to
open how I need it, but it refuses to open the second report. I know it is
an issue with my coding, and I am not sure what to do next. It says
something about ambiguous commands, so i am not sure how to combine the two
codes together. Thanks for the help!

Here is my coding:

Private Sub CommandOpen6135r_Click()
On Error GoTo Err_CommandOpen6135r_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "r6135FOREMAIL"

stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria ...
End Sub


Private Sub CommandOpen6135r_Click()
On Error GoTo Err_CommandOpen6135r_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "r6135EMAIL"

stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria ...
End Sub


Combine the two procedures.

For example:

Private Sub CommandOpenBoth_Click()
On Error GoTo Err_Code

Dim stLinkCriteria As String
stLinkCriteria = "[EMPLOYEE ID] = " & Me![EMPLOYEE ID]

DoCmd.OpenReport "r6135FOREMAIL", acViewPreview, ,
stLinkCriteria
DoCmd.OpenReport "r6135EMAIL", acViewPreview, ,
stLinkCriteria

Exit_Command:
DoCmd.Close
Exit Sub

Err_Code:
MsgBox Err.Description
Resume Exit_Command

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