Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple data sets in a graph. (Access 2000)

    Hans,

    You assisted me with a problem of generating a graph with the source data being selected from two drop down menus. The code you supplied works perfectly. However, I have now been tasked to get multiple sets of data displayed on a single graph using drop down menus to select the source data. The X-Axis' will be the same for each data set. I have attempted to alter the code to make this happen. I have started with only trying to get 2 data sets to display. I have attached a stripped down database with my alterations. Below is the original working code that you supplied me.


    Dim strXField As String
    Dim strYField As String
    Dim strXTable As String
    Dim strYTable As String
    Dim strSQL As String

    If IsNull(Me.X_Axis) Then
    MsgBox "Please select a field for the X axis.", vbInformation
    Me.X_Axis.SetFocus

    Exit Sub
    End If

    If IsNull(Me.Y_Axis) Then
    MsgBox "Please select a field for the Y axis.", vbInformation
    Me.Y_Axis.SetFocus

    Exit Sub
    End If

    If Me.X_Axis = Me.Y_Axis Then
    MsgBox "You selected the same field for both axis." & vbCrLf & "Please select a different one.", vbInformation
    Me.Y_Axis.SetFocus

    Exit Sub
    End If

    strXField = Me.X_Axis.Column(2)
    strXTable = Me.X_Axis.Column(3)
    strYField = Me.Y_Axis.Column(2)
    strYTable = Me.Y_Axis.Column(3)

    If strXTable = strYTable Then
    strSQL = "SELECT [" & strXField & "], [" & strYField & _
    "] FROM [" & strXTable & "] ORDER BY [" & strXField & "]"
    Else
    strSQL = "SELECT [" & strXTable & "].[" & strXField & "], [" & _
    strYTable & "].[" & strYField & "] FROM [" & strXTable & _
    "] INNER JOIN [" & strYTable & "] ON [" & strXTable & _
    "].[Name] = [" & strYTable & "].[Name] ORDER BY [" & _
    strXTable & "].[" & strXField & "]"
    End If

    With Me.Graph()
    .RowSource = strSQL
    End With

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

    Re: Multiple data sets in a graph. (Access 2000)

    I don't have the slightest idea what you want to do. The combo boxes on the form in the database have a non-existing row source, so I don't know what the user is expected to select.

    Please explain in clear and simple terms what you are trying to plot in the graph.

  3. #3
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multiple data sets in a graph. (Access 2000)

    Hans,

    I have attached a new stripped down database with two forms. The form titled "Parametrics_Working" is the form you assisted me with a while ago. It works. It allows the user to choose the data to be displayed in the graph based on the options given in 2 drop down menus. The options in the drop down menus are the fields avalable in the tables. It allows the user to choose any field for the X-Axis and any Field for the Y-Axis.

    The form titled "Parametrics_New" is exactly the same as "Parametrics_Working" with one exception. I need the user to be able to choose multiple fields in the Y_Axis to be graphed against a single field in the X-Axis. At this time, the form "Parametrics_New" only has two drop downs for the Y-Axis. I plan to increase it to 4 or 5. The drop downs now work.

    Note: When choosing different fields from the drop down menus, try to limit your choices to the following: Gross Takeoff Weight, Empty Weight, Payload Weight, Fuel Weight, and Crew Weight. These are the only fields at this time with data.

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

    Re: Multiple data sets in a graph. (Access 2000)

    See the attached version. Since you only included data for one table, the code hasn't been tested for selections from different tables, so there may well be an error there.
    This is going to be VERY complicated if you want to add more data series. The number of combinations grows fast!

  5. #5
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multiple data sets in a graph. (Access 2000)

    Thanks Hans. That worked. I had to change a few things because I forgot that I chaged some field names, but it works.

    Thanks again,

    Mike

Posting Permissions

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