|
有1个electric表和一个查询electric query,我想把query里的记录的数据转到表里,请教高手下面的程序有什么问题?在2007里只运行了第一个循环就出错了, 2000里根本不运行.
Private Sub Command6_Click()
DoCmd.SetWarnings False
DoCmd.OpenTable "electric", acNormal, acEdit
DoCmd.OpenQuery "electric query", acNormal, acEdit
DoCmd.SetWarnings True
Set qrs1 = CurrentDb.OpenRecordset("electric")
Set qrs2 = CurrentDb.OpenRecordset("electric query")
Set qrs3 = CurrentDb.OpenRecordset("electric query")
qrs1.AddNew
qrs1.MoveFirst
qrs2.MoveFirst
qrs3.MoveFirst
qrs3.MoveNext
Rem Do While qrs3.EOF
Do While Not qrs3.EOF
qrs1.Edit
qrs1!start = qrs2!DATE
qrs1!end = qrs3!DATE
qrs1!PO1 = qrs3!PO1 - qrs2!PO1
qrs1!PO2 = qrs3!PO2 - qrs2!PO2
qrs1!PO3 = qrs3!PO3 - qrs2!PO3
qrs1!PO4 = qrs3!PO4 - qrs2!PO4
qrs1!PO5 = qrs3!PO5 - qrs2!PO5
qrs1!PO6 = qrs3!PO6 - qrs2!PO6
qrs1!Type = qrs3!Type
qrs1.AddNew
qrs1.Update
qrs1.MoveNext
qrs3.MoveNext
qrs2.MoveNext
Rem qrs.MoveNext
Loop
MsgBox ("初始化完毕。")
qrs1.Close
qrs2.Close
qrs3.Close
End Sub |
|