This tutorial is not available for Accredo Mercury.
This tutorial shows you how to create a GL Financial Report that will iterate through departments, running the report for each department.
F9). The wizard will create a report for you. You could run this report several times, once for each department. Instead, we will modify the report to iterate through all departments, automatically producing a report for each department and a consolidated total report.
F4).F4).F2). scForm = Nothing line, add the following code. This will find the first department in the range, and determine whether the results will be consolidated:Dim tblCODept as Object
tblCODept = OpenTable("CODept")
tblCODept.IndexName = "Department"
If Department <> "" Then
tblCODept.SetRange(Department)
tblCODept.First
Consolidated = False
Else
tblCODept.First
Department = tblCODept.DepartmentCode
Consolidated = True
End If
DepartmentName = tblCODept.DepartmentName
If Department <> "" Then
Data = CreateObject("Accredo.CODepartmentData")
Data.FindExact(Department)
DepartmentName = Data.DepartmentName
End If
Data = Nothing
F9) the changes to the code.F2). tblCODept.Next
If Not tblCODept.EOF then ' If there is another Department in the range of departments selected, continue
RestartIterators ' Restart the report from the first iterator
bandRestart.ForceNewPage = True 'Restart on a new page
bandRestart.ForceNewWorksheet = True 'Restart on a new worksheet
Department = tblCODept.DepartmentCode
DepartmentName = tblCODept.DepartmentName
Dim Iter as Object
For I = 0 To Iterators.Count - 1 'Loop through each of the Iterators
Iter = Iterators[I]
' Only modify iterators that select some accounts
If Iter.BranchRange <> "" or Iter.DepartmentRange <> "" or Iter.Segment1Range <> "" or Iter.Segment2Range <> "" or Iter.Selection <> "" Then
Iter.ExcludeNull = Not(IncludeNilBalances)
Iter.DepartmentRange = Department
End If
Next 'Repeat for the next Iterator
Iter = Nothing
If UntransferredBatches Then 'If there are untransferred batches, don't enable the bandUnTransferred
bandUnTransferred.Enabled = False
End If
If UnpostedBatches Then 'If there are unposted batches, don't enable the bandUnTransferred
bandUnposted.Enabled = False
End If
ElseIf Consolidated = True then 'If this is the last in the range, and the report is consolidated, continue
RestartIterators ' Restart the report from the first iterator
bandRestart.ForceNewPage = True 'Restart on a new page
bandRestart.ForceNewWorksheet = True 'Restart on a new worksheet
Department = "" 'Set department to blank, as the departments are consolidated
DepartmentName = "Consolidated for All Departments"
Dim Iter as Object
For I = 0 To Iterators.Count - 1 'Loop through each of the Iterators
Iter = Iterators[I]
' Only modify iterators that select some accounts
If Iter.BranchRange <> "" or Iter.DepartmentRange <> "" or Iter.Segment1Range <> "" or Iter.Segment2Range <> "" or Iter.Selection <> "" Then
Iter.ExcludeNull = Not(IncludeNilBalances)
Iter.DepartmentRange = Department
End If
Next 'Repeat for the next Iterator
Iter = Nothing
If UntransferredBatches Then 'If there are untransferred batches, don't enable the bandUnTransferred
bandUnTransferred.Enabled = False
End If
If UnpostedBatches Then 'If there are unposted batches, don't enable the bandUnTransferred
bandUnposted.Enabled = False
End If
Consolidated = False
End If
F9) the changes to the code.Ctrl+R). If you select a Department, the report will run for the selected department. If you leave the Department selection clear, the report will run for each department, and for the consolidated departments.See also the GL Tutorial: Saturn Report to Iterate Branches.