Author: Dwayne Hoffpauir, EDS Corporation
Further discussion should take place in this topic.
The attached report uses VBA to create a separate report tab filtered for each value of a given field. The sample is based on the Island Resorts Marketing universe, and creates a separate report tab for each resort. The report tab name for each is changed to reflect the filtered value. The first tab is cloned as many times as needed, then the original tab is deleted from the document. The VBA code is included here for easier reference:
Private Sub Document_AfterRefresh()
Dim Rpt As Report
Dim Var As DocumentVariable
Dim i As Long
Set Var = ThisDocument.DocumentVariables("Resort")
If UBound(Var.Values(boUniqueValues)) > 0 Then
Set Rpt = ThisDocument.Reports(1)
For i = 1 To UBound(Var.Values(boUniqueValues))
Set Rpt = Rpt.Duplicate
Call Rpt.AddComplexFilter("Resort", "= <Resort> = """ & _
Var.Values(boUniqueValues)(i) & """")
Rpt.Name = Var.Values(boUniqueValues)(i)
Next i
Call ThisDocument.Reports(1).Delete
End If
End Sub
Report tab for each value.rep (50.0 KB)
Dwayne Hoffpauir (BOB member since 2002-09-19)