Results 1 to 4 of 4
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Dynamic no of cols in Graphs (Access 2003 SP2)

    I have a form graph which has 5 columns, is there a way to dynamically setup the graph at run time to set the number of columns?

    eg. i have 4 columns and i only wish to show 2 of them

  2. #2
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dynamic no of cols in Graphs (Access 2003 SP2)

    Hi Pat, nowadays I have totally abandoned Graph in favour of Pivot Charts but in any case you have to change the chart row source via code. Here's a snippet from a chart-bearing report I prepared 6 years ago.
    Private Sub Report_Activate()
    Dim cmd As New ADODB.Command
    cat.ActiveConnection = CurrentProject.Connection
    If (Forms!Maschera1!List10 = "Lombardia" Or Forms!Maschera1!List10 = "Italia") Then
    cmd.CommandText = "SELECT anno, sum(" & Forms!Maschera1!List10.Value & ") FROM pippo group by anno"
    Else
    cmd.CommandText = "SELECT anno, sum(selectedfields) FROM pippo group by anno"
    End If
    With cat.Views
    '.Append "qryChartSource", cmd
    .Item("qrychartsource").Command = cmd
    End With
    Set cmd = Nothing

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Dynamic no of cols in Graphs (Access 2003 SP2)

    Giorgio is using a fixed query (qrychartsource) as row source of the chart object and changing its SQL. You can also use the SQL string directly as row source of the chart object, and change this string as needed.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Dynamic no of cols in Graphs (Access 2003 SP2)

    Thanks Hans, that's what i will do, change the row source of the chart object.

    Thanks also giorgio.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •