Office中国论坛/Access中国论坛
标题:
[求助]怎样用ado写主从记录的窗口?
[打印本页]
作者:
lanchong
时间:
2005-3-19 18:48
标题:
[求助]怎样用ado写主从记录的窗口?
我想把access的程序与数据分开,但不知道主子窗口应用时,怎么去让子窗体与主窗体的数据链接自动刷新,谁能给个案例
单个窗口我是照搬以下案例,但主子窗口怎么办?
Option Compare Database
Option Explicit
Public conn As ADODB.Connection
Public rst As ADODB.Recordset
Private Sub Form_Close()
conn.Close
Set rst = Nothing
Set conn = Nothing
End Sub
Private Sub Form_Open(Cancel As Integer)
Set conn = CurrentProject.Connection
'Create an instance of the ADO Recordset class, and
'set it's properties
Set rst = New ADODB.Recordset
With rst
Set .ActiveConnection = conn
.Source = "SELECT * FROM tblCustomers"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rst
End Sub
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3