Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Reports Popping Up

Status
Not open for further replies.

CCPKGUY

IS-IT--Management
Feb 25, 2013
30
US
I have a question. Look at the script below. Where it says stDocName and strQueryName how to add multiple entries? When I click on that button to generate the report I would like for multiple reports to pop up.


Private Sub Generate_CCPK_Employee_Discount_Report_DblClick(Cancel As Integer)

On Error GoTo Err_Generate_CCPK_Employee_Discount_Report_DblClick

Dim stDocName As String
stDocName = "CCPK Discount Employees Fulltime1"
Dim stWhere As String
strQueryName = "CCPK Discount Employees"
If Not IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[trans_date] <=" & SQLdate(Me.txtEnding)
ElseIf IsDate(Me.txtBeginning) And Not IsDate(Me.txtEnding) Then
stWhere = "[trans_date] >= " & SQLdate(Me.txtBeginning)
ElseIf IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[trans_date] Between #" & Me.txtBeginning & "# And #" & Me.txtEnding & "#"

End If
'MsgBox stWhere
Debug.Print "Beginning: " & Me.txtBeginning & "Ending: " & Me.txtEnding & " StWhere: " & stWhere
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
Exit_Generate_CCPK_Employee_Discount_Report_DblClick:

Exit Sub
Err_Generate_CCPK_Employee_Discount_Report_DblClick:
MsgBox Err.Description

End Sub
 
As long as none are set up as pop up/dialog.
Code:
stDocName = "CCPK Discount Employees Fulltime1"
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
stDocName = "Your Report 2"
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
stDocName = "Your Report 3"
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
....
 
Thanks for the quick response MajP but I am confused where do I put your answers in my script?


stDocName = "CCPK Discount Employees Fulltime1"
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
stDocName = "Your Report 2"
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
stDocName = "Your Report 3"
DoCmd.OpenReport stDocName, acViewPreview, , stWhere


Private Sub Generate_CCPK_Employee_Discount_Report_DblClick(Cancel As Integer)

On Error GoTo Err_Generate_CCPK_Employee_Discount_Report_DblClick

Dim stDocName As String
stDocName = "CCPK Discount Employees Fulltime1"
Dim stWhere As String
strQueryName = "CCPK Discount Employees"
strQueryName = "Report 2
If Not IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[trans_date] <=" & SQLdate(Me.txtEnding)
ElseIf IsDate(Me.txtBeginning) And Not IsDate(Me.txtEnding) Then
stWhere = "[trans_date] >= " & SQLdate(Me.txtBeginning)
ElseIf IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[trans_date] Between #" & Me.txtBeginning & "# And #" & Me.txtEnding & "#"

End If
'MsgBox stWhere
Debug.Print "Beginning: " & Me.txtBeginning & "Ending: " & Me.txtEnding & " StWhere: " & stWhere
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
Exit_Generate_CCPK_Employee_Discount_Report_DblClick:

Exit Sub
Err_Generate_CCPK_Employee_Discount_Report_DblClick:
MsgBox Err.Description

End Sub
 
If I understand correctly, you want to open different reports each using the same criteria (strWhere). Not sure if I see anywhere you are using your query, so I do not know your intent there.


Code:
Private Sub Generate_CCPK_Employee_Discount_Report_DblClick(Cancel As Integer)
  On Error GoTo Err_Generate_CCPK_Employee_Discount_Report_DblClick
  Dim stDocName As String
  Dim stWhere As String

  If Not IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
     stWhere = "[trans_date] <=" & SQLdate(Me.txtEnding)
  ElseIf IsDate(Me.txtBeginning) And Not IsDate(Me.txtEnding) Then
     stWhere = "[trans_date] >= " & SQLdate(Me.txtBeginning)
  ElseIf IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
     stWhere = "[trans_date] Between #" & Me.txtBeginning & "# And #" & Me.txtEnding & "#"
  End If
  Debug.Print "Beginning: " & Me.txtBeginning & "Ending: " & Me.txtEnding & " StWhere: " & stWhere
  stDocName = "CCPK Discount Employees Fulltime1"
  DoCmd.OpenReport stDocName, acViewPreview, , stWhere
  stDocName = "Your Report 2"
  DoCmd.OpenReport stDocName, acViewPreview, , stWhere
  stDocName = "Your Report 3"
  DoCmd.OpenReport stDocName, acViewPreview, , stWhere
 Exit_Generate_CCPK_Employee_Discount_Report_DblClick:
    Exit Sub
 Err_Generate_CCPK_Employee_Discount_Report_DblClick:
    MsgBox Err.Description
End Sub

If you mean something different please explain in more detail. Also you do not really need the stDocName, you can just hard code the report names in the docmd.openreport. Not really saving anything by declaring the variable.
 
I just want to be able to see the other reports that are built like CCPK Discount Employees Fulltime1 since they are he same but with different information on it.
 
It sounds to me that you may want to present this information in a Main report with multiple subreports.

So for the Period xx/xx/xxxx to yy/yy/yyyyy
Employee discount information
other information
some other information 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top