Results 1 to 11 of 11
  1. #1
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442

    Graphing

    I don't do graphing on forms very often so here's my question.



    On a form I have a button with the following code:

    Code:
    (on button click event)
    CheckGraph
    lst_ORAS.Requery
    ctl_Graph.Requery
    CHECKGRAPH just makes the graphing object visible if there's data to display, otherwise sets the visible property false
    requeries a list box with some data in it
    ctl_Graph is my graph object and it correctly updates the graph.

    However, when I add this same code to my add/update button the object is visible (I can see the border) but the actual content of the graph/chart is not visible. If I tab to another form then come back to it, it is.

    Has anyone encountered this and if so how do I get my form to update with the correct data as part of the larger code set? (code below)

    Code:
    Dim db As Database
    Dim ssql As String
    
    If fld_ORASScore < 0 Or fld_orasscore > 49 Then
        MsgBox "ERROR: ORAS Score is out of acceptable range"
    ElseIf IsNull(cbo_Client) Or IsNull(fld_ORASDate) Or IsNull(fld_ORASScore) Then
        MsgBox "ERROR:  A Court Participant, Scoring Date and Score must all be present", vbOKOnly
    Else
        If IsNull(lst_ORAS) Then
            If DCount("*", "tbl_ORAS", "[Client_ID] = " & cbo_Client & " AND [ORAS_Date] = #" & fld_ORASDate & "#") > 0 Then
                MsgBox "ERROR: ORAS Score for this date is already entered"
            Else
                Set db = CurrentDb
                ssql = "INSERT INTO Tbl_ORAS (Client_ID, ORAS_Date, ORAS_Score) VALUES ("
                ssql = ssql & cbo_Client & ", "
                ssql = ssql & "#" & fld_ORASDate & "#, "
                ssql = ssql & fld_ORASScore
                ssql = ssql & ")"
                db.Execute ssql
                db.Close
                ClearForm
                ScoreLabel
            End If
        Else
            If DCount("*", "tbl_ORAS", "[Client_ID] = " & cbo_Client & " AND [ORAS_Date] = #" & fld_ORASDate & "# AND ORAS_ID <> " & lst_ORAS) > 0 Then
                MsgBox "ERROR: ORAS Score for this date is already entered"
            Else
                Set db = CurrentDb
                ssql = "UPDATE Tbl_ORAS SET "
                ssql = ssql & "ORAS_Date = #" & fld_ORASDate & "#, "
                ssql = ssql & "ORAS_Score = " & fld_ORASScore & " "
                ssql = ssql & "WHERE ORAS_ID = " & lst_ORAS
                db.Execute ssql
                db.Close
                lst_ORAS.Requery
                ClearForm
                ScoreLabel
            End If
        End If
    End If
    
    CheckGraph
    lst_ORAS.Requery
    ctl_Graph.Requery
    Clearform and ScoreLabel are functions that are unrelated to the graph.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    This is what I do:

    Private Sub btnGraph_Click()
    SaveData
    Me.Refresh
    FormatGraph
    End Sub
    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
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'm trying to make this work in a section of code that updates/adds data so what are

    SaveData
    FormatGraph

    Are those functions you have within your form? Or are they functions related to a specific reference, if so what's the reference?
    Because I can get a button click refresh to work correctly. It's when I add it to the larger set of code that the refreshing goes horribly wrong.

    If I put message boxes between the lines of code when the code is done running (in the larger set) the graph displays fine.
    If I don't put in any message boxes when the graph is requeried I just end up with the border and nothing else

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes, those are custom procedures to save calculated data (don't say it, I know that is not advised but it is necessary in this db) and then to custom format graph properties (set axis scale, axis labels, etc). Although probably doesn't matter, I set the graph visible in the FormatGraph procedure.

    The graph RowSource property is dependent on key value on the form:
    SELECT M, D, FD, ZD, ZDM FROM GraphProctor WHERE LabNum=[tbxLabNum];

    Note that my code refreshes the entire form, not specifically the graph, and it is before the FormatGraph call and really does not impact the graph display. I don't have any code that specifically requeries/refreshes graph.

    Data is committed to table, form record is refreshed, graph formatted.
    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
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    That's the whole problem June if I have a button with just the

    me.refresh
    or
    ctl_Graph.requery it works just fine

    if I add anything else including if I move the add/update data to it's own function and call that function the refresh the form it gives me the border of the graph but nothing in the actual graphing area. If I tab away from the form and back, the graph looks like it should, if I step through the code with message boxes popping up, the graph looks like it should.

    If I run the same code without the message box breaks the graphing area is again blank with just the border showing.

    I can't figure out why.

    I have a button that's just a 'click here to update the graph' that does the requery just fine, displays the viewable area just fine but won't work if I add any more code to it.

    My Save/Update button is now calling an add/update function then doing me.refresh or ctl_Graph.requery and neither one updates the graph correctly.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    My button has other code (the procedure calls) and the graph still shows data. Can't see what in your code interferes. Do wonder why using INSERT and UPDATE actions. Are those actions affecting graph data?

    I analyse graph issues best when I can work with objects - if you want to provide.
    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
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Here's a stripped down version. To get to the form with the graph just double click either of the people in the only frm_calendar list box.

    I want the graph to be updated when the add/update button is clicked.

    The button 'click here to update the graph' works fine and I am trying to find a way to make it work on the add/update button.

    DrugCourt.zip

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I clicked on 10057 and opened the graph form. I entered values: 2/10/2013 and 40, clicked Add/Update and the graph reflects the new data point. Wow, can't replicate the issue.

    Testing with Windows XP and Access 2007.
    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.

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I've tested on access 2007 and a 2013 machine and both perform the same way.

    just my luck

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    ok... just tested on another 2007 machine and it worked as I wanted it to... terrific.

    I just love inconsistent results!

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You mean they all fail? Weird.

    Okay, see your new post. Guess that is some progress.
    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.

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

Similar Threads

  1. Graphing/Charting - Access vs. Excel
    By Paul H in forum Forms
    Replies: 11
    Last Post: 06-06-2012, 02:43 PM
  2. Graphing a value between two dates
    By amcalabrese in forum Access
    Replies: 5
    Last Post: 04-19-2011, 05:18 AM
  3. Pie Graphing problem
    By newtoAccess in forum Reports
    Replies: 6
    Last Post: 12-13-2010, 09:36 AM
  4. Replies: 0
    Last Post: 07-22-2010, 07:43 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