HandsOn Writing the Form AfterLayout Event Procedure

1. In the Database window, select the Sales Analysis Subform 2 form and click the Design button.

2. Choose Edit | Select Form.

3. Choose View | Properties to activate the Form properties sheet.

4. Click the Event tab, set the After Layout property to [Event Procedure], and press the Build button (...).

5. Access will create the event procedure stub. Enter the following Form_AfterLayout event procedure:

Private Sub Form_AfterLayout(ByVal drawObject As Object) Dim oSeriesDropZ As Object

Me.ChartSpace.ChartSpaceLegend.Top = 50 Set oSeriesDropZ = Me.ChartSpace.DropZones(chDropZoneSeries) oSeriesDropZ.Top = 30 End Sub

In the procedure above, the ChartSpace object represents the chart workspace. The ChartSpaceLegend property of the ChartSpace object returns a chLegend object that represents the chart workspace legend. To reposition the chart legend on the screen, its Top property was set to 50 pixels. Along with the chart legend, the procedure repositions the Last Name button in the series drop zone by using the DropZones method of the ChartSpace object. This method takes one required argument, ChartDrop-ZonesEnum, which represents the drop zone you want to format.

ChartDropZonesEnum can be one of the following constants:

chDropZoneCategories = 2

chDropZoneCharts = 4

chDropZoneData = 3

chDropZoneFilter = 0

chDropZoneSeries = 1

6. Switch to the Sales Analysis Subform 2 form and choose View | PivotChart View. When the form opens you should see the chart legend and the Last Name button positioned in the top area of the PivotChart view.

0 0

Post a comment