请各位前指点下列程序错在哪?我有两个.mbd数据库,一个命名为:AccCost_Db.mbd(有密码),另一个名为AccountCost.mbd,在AccountCost.mbd中有一个窗体,窗体中含有子窗体"Child_Materil",现希望在Load窗体时子窗体中自动显示AccCost_Db.mbd数据库中,表"Material_Code_Name"中的所有记录.我写了下面这段但运行后显示不出记录,也没有任何报错信息.敬请各位指教!!
Private Sub Form_Load() '材料录入窗口加载事件
Dim cnn_chil As ADODB.Connection
Dim Rs_chil As ADODB.Recordset
Set cnn_chil = New ADODB.Connection
Set Rs_chil = New ADODB.Recordset
Dim chil_query As QueryDef
Dim chil_Str As String
cnn_chil.Open "provider=Microsoft.jet.OLEDB.4.0;Password=;Jet OLEDB:Database Password=RuCost1688;Persist Security Info=False;Data Source=D:\AccCost\AccCost_Db.mdb"
Rs_chil.Open "Material_Code_Name", cnn_chil, adOpenKeyset, adLockOptimistic, adCmdTable
chil_Str = "select * from D:\AccCost\AccCost_Db.mdb.Material_Code_Name"
CurrentDb.QueryDefs.Refresh
On Error Resume Next
CurrentDb.QueryDefs.Delete ("Auto_Query") '创建查询前先删除该查询
Set myqur = CurrentDb.CreateQueryDef("Auto_Query", chil_Str)
With Me.Child_Materil.Form
.RecordSource = myqur.Name '定议列表框数据源
'.RowSource = myqur.Name '定议列表框数据源
Me.Child_Materil.Requery
End With
cnn_chil.Close: Set cnn_chil = Nothing: Set Rs_chil = Nothing
End Sub
在Access vb中,如何对子窗体设定数据源