先谢谢mccad大师! Dim wr As Workspace '声明工作空间变量,为打开数据库提供空间 Dim db As Database '声明数据库对象变更,用于打开数据库 Dim dl As Recordset '声明数据库表,用于打开数据库库表 Dim xl As Recordset Dim DTYPE As Recordset Dim DLOAD As Recordset Dim DSPEED As Recordset Dim DNBE As Recordset Dim DNBS As Recordset Dim DRMax As Recordset Set wr = CreateWorkspace("", "admin", "", dbUseJet) Set db = wr.OpenDatabase("C:\Program Files\Database.mdb", False, True, "") Set dl = db.OpenRecordset("Data", dbOpenDynaset, dbReadOnly) Do If dl.EOF = False Then cobType.AddItem dl.Fields("Type").Value dl.MoveNext Else Exit Do End If Loop
以上为Access连接部分,实际上我是要根据Access中的DTYPE、DLOAD、DSPEED、DNBE、DNBS、和DRMax,总共6列的数据来最终查找出一条记录,并将找出的这条记录中的其它字段的数据赋值给AutoCAD VBA窗口中的相应控件。
|