Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

How to pass a filtered recordset of a form  to a chart?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Saintor - 14 Feb 2006 17:20 GMT
This is for A97 in runtime or MDE mode.

My intent was to define a temporary query using the recordsetclone property
/ filter / orderby.  The controlsource of my chart would be based on a
grouped query based on this temporary query.

Is this the best way or is there another one more efficient?

Is it possible in a runtime environment to change the format of an axis (by
Week ---> by Month) or the chart controlsource on report opening?

TIA.
Br@dley - 15 Feb 2006 02:05 GMT
> This is for A97 in runtime or MDE mode.
>
[quoted text clipped - 7 lines]
> axis (by Week ---> by Month) or the chart controlsource on report
> opening?

Easiest option would be to have two versions of the graph and display the
appropriate one.

You can pretty much manipulate anything via the Graph object in code... if
you have to.

Changing the axis from Week to Month really means changing the chart's
source data and then changing the axis label.

eg. to change X axis label

Sample call: SetChartXTitle Me![MyGraph], "Monthly"

Function SetChartXTitle(ByRef pGraphObject As Object, pChartPeriod As
String)
 DoCmd.Hourglass True
 Dim MyGraph As Object
 Set MyGraph = pGraphObject.Object.Application
On Error Resume Next
 If pChartPeriod = "Monthly" Then
   'MyGraph.Chart.Axes(1, 1).TickLabels.Orientation =
xlTickLabelOrientationHorizontal
   MyGraph.Chart.Axes(1, 1).HasTitle = True
   MyGraph.Chart.Axes(1, 1).AxisTitle.Text = "Month"
 Else
  'MyGraph.Chart.Axes(1, 1).TickLabels.Orientation =
xlTickLabelOrientationUpward
   MyGraph.Chart.Axes(1, 1).HasTitle = True
   MyGraph.Chart.Axes(1, 1).AxisTitle.Text = "Week Commencing"
 End If
 MyGraph.Update
 Set MyGraph = Nothing
 DoCmd.Hourglass False
End Function

Sample code to reset the source data contained in the graph object (only
needed if you want to manually change the Graph's datasheet)

'Clear datasheet
 MyGraph.Datasheet.Cells.ClearContents

 'If no chart data then quit
 If rs.RecordCount = 0 Then Exit Function
 FieldCount = rs.Fields.Count
 If FieldCount < 2 Then Exit Function

 'Add data
 row = 2
 'rs.MoveFirst
 Do Until rs.EOF
   For col = 1 To FieldCount
     If IsNull(rs.Fields(col - 1)) Then
       MyGraph.Datasheet.Cells(row, col).ClearContents
     Else
       MyData = rs.Fields(col - 1)
       MyGraph.Datasheet.Cells(row, col) = MyData
     End If
   Next
   rs.MoveNext
   row = row + 1
 Loop

Signature

regards,

Br@dley

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.