例子:在ADP项目中使用 Mdb
先在 VBA 编辑器中,引用 Microsoft DAO 3.6 Library
在ADP项目中创建 UseMdb 窗口
添加如下代码:
Option Compare Database
Dim mdb As DAO.Database
Dim mdbWs As DAO.Workspace
Dim mdbRs As DAO.Recordset
Private Sub Form_Load()
Dim strSQL As String
strSQL = "SELECT * FROM 客户"
Set mdbWs = DBEngine.Workspaces(0)
Set mdb = mdbWs.OpenDatabase(CurrentProject.Path & "\Northwind.mdb")
Set mdbRs = mdb.OpenRecordset(strSQL)
Set Me.Recordset = mdbRs
Me.客户ID.ControlSource = "客户ID"
Me.公司名称.ControlSource = "公司名称"
Me.联系人姓名.ControlSource = "联系人姓名"
End Sub
结果如图:
[此贴子已经被zhuyiwen于2002-3-28 20:47:25编辑过]
|