各位: 下面是用ADO打开多个数据库的代码,总觉得不是很好。有没有更简便的方法?谢谢? Sub Posting() ' 分解组件,写入SectionReduce表 Dim sers As New ADODB.Recordset, seSrc As String Dim bomrs As New ADODB.Recordset, bomSrc As String Dim rers As New ADODB.Recordset, reSrc As String seSrc = "SELECT * FROM SectionIo WHERE Posting = False" reSrc = "SELECT * FROM SectionReduce" ConnectionCurrentDb sers.Open seSrc, Cnct, 0, 3 ConnectionCurrentDb rers.Open reSrc, Cnct, 0, 3 Do Until sers.EOF bomSrc = "SELECT * FROM Bom2Material WHERE [Model] Like '" & sers!Model & "'" & _ " AND [Section] Like '" & sers!Section & "'" ConnectionCurrentDb bomrs.Open bomSrc, Cnct, 0, 1 Do Until bomrs.EOF rers.AddNew rers!SIoId = sers!SIoId rers!Material = bomrs!Material rers!Qty = sers!Qty * bomrs!dosage rers.Update bomrs.MoveNext Loop bomrs.Close sers.MoveNext Loop CloseCurrentCnn sers.Close rers.Close Set sers = Nothing Set rers = Nothing Set bomrs = Nothing End Sub
|