Results 1 to 7 of 7
  1. #1
    PhilA1960 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    4

    Populate Graph From A Value List Not A Table Or Query

    I am presuming you can populate a graph via code with a list of numbers and not use a table or query.

    I have a Sub-Form which has two particular number fields I am interest in. Number A is a Total and B is a Sub Total of A.
    I would like to create a pie-chart from A - B (the non B calculation) and B. The pie-chart would then represent A.
    On the properties of the Graph I have changed 'Row Source Type' to Value List.
    But not sure of the syntax to populate 'Row Source'

  2. #2
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,985
    the construct you need is the values separated by semi colons e.g. for a two column rowsource you might have

    0; productA;1;productB

    assigning via vba your code would be

    mygraphcontrolname.rowsource="0; productA;1;productB"

    the above is based on a list or combobox but the principle should be the same, however you may need to include headers in which case you would have

    mygraphcontrolname.rowsource="header1;header2;0; productA;1;productB"

  3. #3
    PhilA1960 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    4

    Trying to work the example.

    I have entered data based on the example. 10;ProductA;10;ProductB

    All I get is blank graph

    If I click on the Graph in Form View Mode I get this datasheet. (see attached PDF)

    If I manipulate the datasheet, I get what I would expect.

    If reopen the form it goes back to the empty graph.

    Can I presume the datasheet is editable from code and does anyone know how to.
    Attached Files Attached Files

  4. #4
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,985
    as I said - you probably need to include headers - or as another thought perhaps set column headers to false

    Can I presume the datasheet is editable from code and does anyone know how to.
    too vague a question, a datasheet has a recordset - which might be a table or might be a query. a query might be editable or it might not, depending on its construction. Either way your data would need to be in tables

  5. #5
    PhilA1960 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    4
    The example 10;ProductA;10;ProductB is putting a single line out. To make the graph I want to work the data would have to be vertical in the datasheet.

    See PDF on a previous post.

    Therefore is it possible to insert something into the string, a command to move down a line, for example.

    Header1;Header2;[CRLF];10;ProductA;[CRLF];10;ProductB

    I know CRLF is a print or notepad type statement but is there a code I can put in the Row Source to put information on the line below.

  6. #6
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,985
    have you set the column count to 2?

    This is not how I create graphs (I just use a query) so new territory for me. I've been explaining how value lists are created for list and combo boxes and assume it will be the same for graphs since the properties look to be the same.

    It may be that although value lists can be created in graph control, they don't actually work

  7. #7
    PhilA1960 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    4
    A lightbulb moment.

    With Ajax's guidance, it became obvious that all I have to do is calculate the variables I need and populate a table in the format I require via vba.

    I will let you know how I get on.

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

Similar Threads

  1. Replies: 24
    Last Post: 07-28-2015, 10:50 AM
  2. Replies: 5
    Last Post: 03-23-2014, 09:01 AM
  3. Replies: 3
    Last Post: 10-10-2013, 08:06 AM
  4. Export Query/Table to PowerPoint Graph
    By BED in forum Import/Export Data
    Replies: 0
    Last Post: 03-10-2011, 12:27 PM
  5. Replies: 3
    Last Post: 01-10-2011, 10:31 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
  •  
Tech Forums: Microsoft Office Forums