Microsoft Developer Network > Forums Home > Microsoft ISV Community Center Forums > Visual Basic for Applications (VBA) > Help with Progress Bar - getting error 7952 (acSysCmdUpdateMeter)
Ask a questionAsk a question
 

QuestionHelp with Progress Bar - getting error 7952 (acSysCmdUpdateMeter)

  • Wednesday, November 04, 2009 8:00 AMCondor10101010101 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi All,

    I have an access app and I'm trying to incorporate a progress bar as a function loops through a query recordset. 

    I'm able to initiate the progress bar by:

    syscmd acSysCmdInitMeter, message, total#

    but when I try to increment the progress bar:


    syscmd acSysCmdUpdateMeter, progress#
    
    
    
    
    I get error: '7952 You made an illegal function call'

    Any ideas how to fix this?

    Thank you!

All Replies

  • Wednesday, November 04, 2009 9:26 AMCinzia PaganiMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Condor,
    here you can find a working  example, http://support.microsoft.com/kb/210474/en-us
    Wich Access version are you using?
    Cinzia


    Sito RIO
    Il mio Blog
  • Wednesday, November 04, 2009 5:20 PMCondor10101010101 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code

    Thank you Cinzia!

    The example helps.  However, I'm still experiencing the same issue.  I'm using Access 2007.

    Here's a sample of my code:

    Set rst = CurrentDb.OpenRecordset("tbl_table1")
    Count = rst.RecordCount
    Progress_Amount = 100 / Count
    
    If rst.RecordCount <> 0 Then
        rst.MoveFirst
        Do Until rst.EOF
            If rst![Show] = "True" Then
            ...
                rst.MoveNext
            End If
    
            RetVal = SysCmd(acSysCmdUpdateMeter, Progress_Amount)
        Loop
    End If
    
    CurrentDb.Close
    rst.Close
    Set rst = Nothing<br/>
    
    When it tryes to increment the Progress Bar the Error mentioned before gets thrown.  :(

    Any thoughts?  Thank you so much!!!
  • Wednesday, November 04, 2009 9:24 PMCinzia PaganiMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi,
    Progress_Amount must be an integer type and must be an increasing number for each cycle.
    Try this way:
    Set rst = CurrentDb.OpenRecordset("tbl_table1")
    rst.MoveLast
    count= rst.RecordCount
    Progress_Amount = 1
    retval = SysCmd(acSysCmdInitMeter, "Reading Data...", count)
    
    If rst.RecordCount <> 0 Then
        rst.MoveFirst
        Do Until rst.EOF
            If  rst![show]  Then
    
                  rst.MoveNext
            End If
    
            retval = SysCmd(acSysCmdUpdateMeter, Progress_Amount)
            Progress_Amount = Progress_Amount + 1
        Loop
    End If
    rst.Close
    Set rst = Nothing
    
    

    Cinzia


    Sito RIO
    Il mio Blog
  • Thursday, November 05, 2009 9:38 PMCondor10101010101 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Thank you Cinzia!  I tried your example but I still get the same error

       Run-time error '7952':
       You made an illegal function call.


    This gets thrown the first time trying to execute

    retval = SysCmd(acSysCmdUpdateMeter, Progress_Amount)
    
    

    Any thoughts as to why this is happening?

    I'm declaring the following:

    Dim Count As Integer
    Dim Progress_Amount As Integer
    Dim RetVal As Variant
    
    Thank you!
  • Thursday, November 05, 2009 9:54 PMCondor10101010101 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Cinzia,

    Here's some interesting information,  I just tried the following before I ran the recordset:

    SysCmd acSysCmdInitMeter, "Hello", 200
        SysCmd acSysCmdUpdateMeter, 100
        SysCmd acSysCmdClearStatus
    
    And it worked OK.  However, when I incorporate the exact same from above into the recordset, I get the same error.  ?!?  I'm confused.
  • Thursday, November 05, 2009 10:10 PMCinzia PaganiMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,
    I'm confused too!
    Can you follow the cycle on recordset step by step with F8 to see if the error is on
    SysCmd acSysCmdUpdateMeter, 100, if it happens on first   cycle, or after X cycle or if there is
    something else that go in error?

    Can you post the exact code you have used for the test?



    Cinzia


    Sito RIO
    Il mio Blog
  • Thursday, November 05, 2009 10:41 PMCondor10101010101 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi Cinzia,

    Just want to say THANK YOU for your help thus far!  :)

    I think I know the source of my error.  Besides recordset1, I have 3 addtional recordsets.  I tried the code again with only one recordset and it worked as expected.  However, I need to incorporate the progress bar into my code.  Let me give you an example of my code:

    Dim rst As Recordset
    Dim rst2 As Recordset
    Dim rst3 As Recordset
    Dim rst4 As Recordset
    Dim OID As Integer
    Dim Count As Integer
    Dim Progress_Amount As Integer
    Dim test As Integer<br/>
    Set rst = CurrentDb.OpenRecordset("tbl_table1")
    Set rst2 = CurrentDb.OpenRecordset("tbl_table2")
    Set rst3 = CurrentDb.OpenRecordset("tbl_table3")
    Set rst4 = CurrentDb.OpenRecordset("tbl_table4")
    
    rst.MoveLast
    Count = rst.RecordCount
    Progress_Amount = 1
    
    '**********Initialize the progress meter.*************************
    SysCmd acSysCmdInitMeter, "Test Message!!!", Count
    '*****************************************************************
    
    If rst.RecordCount <> 0 Then
        rst.MoveFirst
        
        Do Until rst.EOF
            If rst![Show] = "True" Then
            
            '*********Incrementing Progress Bar ***********************
            test = rst.AbsolutePosition
            If test >= 1 Then Progress_Amount = Progress_Amount + 1
                SysCmd acSysCmdUpdateMeter, Progress_Amount
            '**********************************************************
            
                rst2.MoveNext
                rst2.AddNew
                ID = rst![ID]
                rst2.Edit
                rst2![OID] = ID
                rst2.Update
    
                rst3.AddNew
                rst3![OID] = ID
                rst3.Update
    
                rst4.AddNew
                rst4![OID] = ID
                rst4.Update
                
                rst.Edit
                rst![Show] = "False"
                rst.Update
                rst.MoveNext
            End If
            OID = 0
        Loop
    End If
    
    CurrentDb.Close
    rst.Close
    Set rst = Nothing
    rst2.Close
    Set rst2 = Nothing
    rst3.Close
    Set rst3 = Nothing
    rst4.Close
    Set rst4 = Nothing
    

    The first loop runs OK but when the 2nd loop happens it errors when it tries the progress bar gets incremented.  Trying to understand why it errors out when more than one recordsets are incorporated. 

    Thank you Cinzia!
  • Friday, November 06, 2009 1:36 PMCinzia PaganiMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Condor,
    it's really a nightmare! :-)
    I  see nothing wrong in your posted code!
    May you made a little accdb that reproduce the problem,  and put it somewhere, so I can download it and test?
    Cinzia


    Sito RIO
    Il mio Blog
  • 12 hours 52 minutes agoCondor10101010101 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Cinzia,

    Thank you so much for your help!  I finally found the cause of my error.  I had another SysCmd  command:  acSysCmdSetStatus.  This was the culprid!  After I removed it the code functioned as expected!

    Again thank you!!!!