用ADO异步查询
Private WithEvents mRstCar as ADODB.RecordsetPrivate Sub mrstCar_FetchProgress(ByVal Progress As Long, ByVal MaxProgress As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
    '另入进度条
End Sub

解决方案 »

  1.   

    请说详细点,我这样写
    Option ExplicitPrivate cnnSource As New ADODB.ConnectionPrivate strSQL As String
    Private strSource As String
    Private WithEvents mRstCar As ADODB.RecordsetPrivate Sub Form_Load()
     
       
       strSource = App.Path & "\xx.mdb"
       cnnSource.Provider = "Microsoft.Jet.OLEDB.3.51"
      
       cnnSource.Open strSource, "Admin" ', "Password", if the database is secure
         
    End SubPrivate Sub sscomOK_Click()
      
       strSQL = "xxxxxx "
     
        With mRstCar
            If .State = adStateOpen Then
               .Close
            End If
            Set .ActiveConnection = cnnSource
            .CursorType = adOpenKeyset
            .LockType = adLockOptimistic
            .Open strSQL
       End WithPrivate Sub mRstCar_FetchProgress(ByVal Progress As Long, ByVal MaxProgress As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
       ...
    End Sub出现对象变量或with块变量没设置如果加上
    set mRstCar As New ADODB.Recordset
    又说“缺少:= 编译错误”哪里出错?请指正。
      

  2.   


    Private WithEvents mRstCar As ADODB.Recordset
    时,使用mRstCar前要使用
    set mRstCar = new ADODB.Recordset
      

  3.   

    我作了修改,运行无问题,但进度却不能显示,哪里出错?请指正。Option ExplicitPrivate cnnSource As New ADODB.ConnectionPrivate strSQL As String
    Private strSource As String
    Private WithEvents mRstCar As ADODB.RecordsetPrivate Sub Form_Load()
     
       
       strSource = App.Path & "\xx.mdb"
       cnnSource.Provider = "Microsoft.Jet.OLEDB.3.51"
      
       cnnSource.Open strSource, "Admin" ', "Password", if the database is secure
         
    End SubPrivate Sub sscomOK_Click()
      
       strSQL = "Select * from Table"
       
       Set mRstCar = New ADODB.Recordset
        With mRstCar
            If .State = adStateOpen Then
               .Close
            End If
            Set .ActiveConnection = cnnSource
            .CursorType = adOpenKeyset
            .LockType = adLockOptimistic
            .Open strSQL
       End WithPrivate Sub mRstCar_FetchProgress(ByVal Progress As Long, ByVal MaxProgress As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
      
      lblTest.Caption=Progress
      ccrpProgress.Value = Progress
      DoEventsEnd Sub