美文网首页
Access vba ADO、DAO方法遍历表中所数据

Access vba ADO、DAO方法遍历表中所数据

作者: KariusJandrick | 来源:发表于2021-08-20 11:17 被阅读0次

    ADO

    Sub test()
    
    Dim cnn As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim fld As ADODB.field
    
    Dim arr()
    
    cnn.Open "provider=microsoft.jet.oledb.4.0;data source=" & ThisWorkbook.Path & "\BssV18.mdb;"
    
    Set cnnschema = cnn.openschema(adSchemaTables)
    i = 1
    Do Until cnnschema.EOF
        Cells(i, 1) = cnnschema!table_name
        cnnschema.MoveNext
        i = i + 1
    Loop
    End Sub
    

    DAO

    Dim rst As DAO.Recordset
        Set rst = CurrentDb.OpenRecordset("表名")
        rst.MoveFirst
        
        Do Until rst.EOF
            If IsNull(rst![字段名]) = False Then
                要执行的东东
            End If
            rst.MoveNext
        Loop
        
    rst.Close
    

    相关文章

      网友评论

          本文标题:Access vba ADO、DAO方法遍历表中所数据

          本文链接:https://www.haomeiwen.com/subject/wbttiltx.html