Results 1 to 7 of 7
  1. #1
    ruthib4 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    29

    SQL and VBA to create a graph or to pass values to a graph

    Hello Again,



    I need your help here, i am using in a form several MS Graphs that i managed to include directly whithin the form, now I need based on different values given by the user to generate those graphs. So i was wondering if i can build a graph using and sql whithin my VBA code or to pass values to the graph using the sql outcome on my VBA as well. Do you have some example i can look at?

    Please and thanks for any help

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I have graphs only on reports but I expect what you want could be done. Possibly have code set values of unbound textboxes and graph RowSource refers to the textboxes for data. What are the given values for - filter criteria?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ruthib4 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    29
    Quote Originally Posted by June7 View Post
    I have graphs only on reports but I expect what you want could be done. Possibly have code set values of unbound textboxes and graph RowSource refers to the textboxes for data. What are the given values for - filter criteria?
    Hi June7, thanks for the help

    the values are as follows:

    Fecha País SumaDeDebit TC
    01/12/2010 México 164896,225330629
    01/01/2011 México 120555,77791725
    01/02/2011 México 129834,1522737
    01/03/2011 México 140783,33769615
    01/04/2011 México 83211,244065
    01/05/2011 México 105398,3671128
    01/06/2011 México 134717,57713455
    01/07/2011 México 117650,5194084
    01/08/2011 México 113590,4254086
    01/09/2011 México 119610,3137715
    01/10/2011 México 134937,8676807
    01/11/2011 México 136863,4601022
    01/12/2011 México 201398,4797529

    There are generated from a SQL in my VBA code.

    Cheers

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    A recordset in VBA cannot be referenced by the graph. What you can do with code is to modify the RowSource property of the graph. A RowSource is just an SQL statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ruthib4 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    29
    Ok, Do not know how?. Can you?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Here is example of my code that sets some properties of graph.
    Code:
        With Me.gphWeight
            .Axes(xlCategory).MinimumScale = MinAC
            .Axes(xlCategory).MaximumScale = MaxAC
            .Axes(xlValue).MinimumScale = MinUWT
            .Axes(xlValue).MaximumScale = MaxUWT
            .Axes(xlValue).MinorUnit = MnrUWT
            .Axes(xlValue).MajorUnit = MajUWT
            .Axes(xlValue, xlPrimary).HasTitle = True
            If Me!Metric = True Then
                .Axes(xlValue, xlPrimary).AxisTitle.Text = "Unit Weight, kg/cu.m"
            End If
        End With
    I have never set the RowSource property so maybe I spoke too soon to say that it could be done, but I think should be like:
    Me.gphWeight.RowSource = "some sql statement here"
    Me.gphWeight.Requery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ruthib4 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    29
    Ok, I'll give a try, thanks a lot June7

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Graph
    By Ray67 in forum Reports
    Replies: 8
    Last Post: 10-15-2011, 10:38 AM
  2. Replies: 3
    Last Post: 01-10-2011, 10:31 AM
  3. Need Zero Values in Table For Graph
    By TexMax007 in forum Access
    Replies: 2
    Last Post: 06-02-2010, 10:02 AM
  4. Form with Subform and Graph
    By DianeG in forum Forms
    Replies: 0
    Last Post: 03-22-2010, 01:47 PM
  5. Chart/Graph
    By Tony McGuire in forum Access
    Replies: 0
    Last Post: 09-13-2009, 04:17 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums