Consulting

Results 1 to 4 of 4

Thread: Visualize state of ADODB recordset in statusbar

  1. #1

    Visualize state of ADODB recordset in statusbar

    Hi, I have a listobject table that was created from ADODB recordset.
    I'd like to dynamically update the Application.StatusBar reflecting current state like Connecting, Fetching, etc.

    Sub test()
        
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim s As String
        Dim SQL As String
        
        s = "/*someConnectionString*/"
        SQL = "/*someReadCommand*/"
        
        cn.Open s
        rs.Open SQL, cn
        
            Do While rs.State > 1
                DoEvents
                If CBool(rs.State And adStateExecuting) Then
                    Application.StatusBar = "Waiting for server...."
                ElseIf CBool(rs.State And adStateConnecting) Then
                    Application.StatusBar = "Connecting...."
                End If
                Do While CBool(rs.State And adStateFetching)
                    DoEvents
                    Application.StatusBar = "Fetching results: " & rs.RecordCount
                Loop
            Loop
        With Sheet1.ListObjects(1).QueryTable
            Set .Recordset = rs
            .Refresh
        End With
        
    End Sub
    Instead of displaying the message in status bar on bottom left, I get to see only ADODB system info with being updated
    recordCount on bottom right.

    Thanks for any advice

  2. #2
    I'm afraid that cannot be done. Even though the rs.Open statement can be set to run asynchonously, it does not report progress until the fetch is completely done.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    I was wrong, it can be done using a class module: https://www.pcreview.co.uk/threads/c...-query.955548/
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  4. #4
    Great, it's working! Thanks a bunch
    Last edited by pulsar777; 11-16-2018 at 12:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •