I have not worked with VB Macros and now need to estimate rewriting a report that contains one. I am more of a BA than a coder and would appreciate if someone can tell me what this macro is doing.
Thanks!
Sub ears_59()
Dim doc As Document
Dim inter As String
Dim gu As Integer
Dim j As Long
Dim mydps As DataProviders
Dim mydp As DataProvider
Dim cols As Columns
Dim col As Column
' Dim rc As Long
Dim rc As Integer
Set doc = Application.ActiveDocument
Set mydps = doc.DataProviders
Set mydp = mydps.Item(1)
Set cols = mydp.Columns
rc = cols.Item(1).Count
' Dim rpt As busobj.Report
Set col = cols.Item(1)
MsgBox (rc & " pages will be printed!")
For j = 1 To rc
'relocated from above to be inside the loop, so I can ERASE it to not use up all the memory
Dim rpt As busobj.Report
' commented out duplicating the report Set rpt = ActiveDocument.Reports(1).Duplicate
Set rpt = ActiveDocument.Reports(1)
rpt.Name = col.Item(j)
inter = col.Item(j)
rpt.AddComplexFilter "EVENT_ID(SQL 1 with EARS FHSQL)", "=<EVENT_ID(SQL 1 with EARS FHSQL)>=" & Chr(34) & inter & Chr(34)
rpt.AddComplexFilter "EVENT_ID(SQL 4 with EARS FHSQL)", "=<EVENT_ID(SQL 4 with EARS FHSQL)>=" & Chr(34) & inter & Chr(34)
rpt.AddComplexFilter "EVENT_ID(SQL 5 with EARS FHSQL)", "=<EVENT_ID(SQL 5 with EARS FHSQL)>=" & Chr(34) & inter & Chr(34)
rpt.ForceCompute
rpt.Activate
ActiveReport.PrintOut
'new statement here
Set rpt = Nothing
Next
End Sub
[Edited, when posting code samples please use the code option for formatting. It will preserve any indenting or formatting that you may have done. Thank you, Andreas.]
Contractor_D (BOB member since 2007-04-13)