Results 1 to 5 of 5
  1. #1
    Markb384 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    44

    Populating a Chart with data from a VBA Array

    Hi guys



    I recently created a pretty big spreadsheet for analysing test results but it was full of small bugs etc. as effectively I was trying to recreate database functions within it. So I have started again using Access instead (of which I am a noob, but I am learning quickly) and it is going at full steam ahead at the moment. There is one small point I am struggling with.

    My results table is structured based on the number of spots seen for a selection of groups from A - M (e.g. group A, 4 spots where seen, group B, 6 spots and so on) along with some information about some other parameters. Each group is subtly different from its neighbour. The number of spots is then compared to a "baseline" value to test for drift. There are three levels of data, a reference, a baseline (for comparing to the reference) and general (which is compared to the baseline).

    The results require analysing the number of spots seen, correcting for group etc. and this is all incredibly easy within VBA (largely as I have similar code already written).

    In my excel version, I managed to create a chart that was populated with an array of data using VBA. This worked perfectly, and I could even change the legend to reference, baseline etc. depending on the data being used at that instance. I am trying to recreate something similar within Access but I am stumbling at the first hurdle. The charts within the Report are based upon data either from a Table or a Query, neither of which are applicable in this case. Is there a way to set the values within the chart manually according to an array I will be creating within VBA? If this isn't possible, what is the best way around this?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Only way I know is to set the RowSource property.

    Could construct an SQL statement to set the RowSource of graph. The SQL has to reference an actual table as the source even if the constructed fields and values don't actually exist in table. This would result in a single record or through use of UNION construct, up to 50 records.

    An alternative is to write data to a 'temp' table and use that as the graph RowSource.
    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
    Markb384 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    44
    Hi June7

    I think a temporary table is probably the easiest way forward I think, largely as I still don't truly understand what I am doing within SQL

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Code options:

    1. open a recordset object of the temp table and add records to the recordset and update the table - this requires a SELECT sql statement to open recordset

    2. insert records directly to temp table with INSERT sql action

    3. open a form bound to the temp table and use code to move to new record and input data from the array
    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
    Markb384 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    44
    Thank you for your reply June, but due to time constraints on this project, my manager has suggested that the graphs take a backseat for now as they don't particularly add anything to the result (apart from looking pretty) and can always be generated by a spreadsheet on a case-by-case basis if ever required.

    Maybe once I have finished with the rest of the db, I will return to them.

    Once again, thank you.

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

Similar Threads

  1. Self Populating Data
    By psbailey42 in forum Access
    Replies: 1
    Last Post: 09-09-2013, 05:20 AM
  2. Put query data in array
    By lawdy in forum Programming
    Replies: 4
    Last Post: 07-01-2013, 04:23 PM
  3. Replies: 3
    Last Post: 02-17-2013, 09:20 PM
  4. Data Populating
    By Zetony in forum Access
    Replies: 11
    Last Post: 11-02-2011, 12:20 PM
  5. Chart Data Max?
    By mikesr in forum Reports
    Replies: 12
    Last Post: 10-08-2010, 07:18 AM

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