ACC2002: PivotChart Series Formatting Is Lost in Linked Subforms (285848)
The information in this article applies to:
This article was previously published under Q285848 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
SYMPTOMS
When you scroll through records on a form that contains a linked subform in PivotChart view, you notice that the formatting for individual series in the PivotChart is lost. For example, trendlines, error bars, and data labels are discarded, and formatting properties such as color and border weight are reset to their defaults.
CAUSE
The PivotChart Web Component is architected to reset formatting when there is no data to format in a series.
RESOLUTION
Write custom Visual Basic for Applications code to programmatically format the members of the PivotChart from the Current event of the main form. To programmatically format series members of a subform in PivotChart view, follow these steps:
- Open the sample database Northwind.mdb.
- On the Insert menu, click Form.
- In the New Form dialog box, click AutoForm: Columnar, click the Employees table in the Choose the table or query where the object's data comes from box, and then click OK. The new form opens in form view.
- On the View menu, click Design View.
- Delete all controls except the EmployeeID, FirstName, and LastName controls.
- In the Database window, drag the Sales Analysis Subform2 form to the new form.
- Set the LinkMasterFields and LinkChildFields properties of the subform to LastName.
- On the View menu, click Code.
- On the Tools menu, click References.
- In the References dialog box, click Browse, and locate the C:\Program Files\Common Files\Microsoft Shared\Web Components\10\OWC10.DLL file.
- Click Open to select the file.
- Click OK to close the References dialog box.
- Add the following code to the module of the form:
Private Sub Form_Current()
Dim objChartSpace As OWC10.ChartSpace
Dim objChart As OWC10.ChChart
Dim objSeries As OWC10.ChSeries
Set objChartSpace = Me.PivotChart.Form.ChartSpace
Set objChart = objChartSpace.Charts(0)
For Each objSeries In objChart.SeriesCollection
With objSeries
'Set Border weight to Thick
.Border.Weight = owcLineWeightThick
'Set Border Color to Black
.Border.Color = 0
'Set Border style to Solid
.Border.DashStyle = chLineSolid
'Add an Error bar if one doesn't exist
If .ErrorBarsCollection.Count = 0 Then
.ErrorBarsCollection.Add
End If
'Add a trendline if one doesn't exist
If .Trendlines.Count = 0 Then
.Trendlines.Add
'Set trendline color to Aquamarine
.Trendlines.Item(0).Line.Color = "AquaMarine"
'Turn off Trendline equation and R-Squared value
.Trendlines.Item(0).IsDisplayingEquation = False
.Trendlines.Item(0).IsDisplayingRSquared = False
End If
End With
Next
End Sub
- On the File menu, click Close and Return to Microsoft Access.
- On the File menu, click Save.
- On the View menu, click Form View.
- Scroll through each record on the main form.
Note that the PivotChart contains an error bar and trendline, and that individual series members retain their formatting.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 11/6/2003 |
---|
Keywords: | kbbug kbnofix KB285848 |
---|
|