|
1、把效果表复制一份格式,命名为“表2”。
2、新增一个模块,把以下内容复制进去并保存。- Sub Test()
- Dim rst1 As New ADODB.Recordset
- Dim rst2 As New ADODB.Recordset
- Dim i As Long
- rst1.Open "表1", CurrentProject.Connection, 1, 3
- rst2.Open "表2", CurrentProject.Connection, 1, 3
- Do Until rst1.EOF
- For i = 6 To 13
- rst2.AddNew
- rst2(0) = rst1(1)
- rst2(1) = rst1(2)
- rst2(2) = rst1(3)
- rst2(3) = rst1(4)
- rst2(4) = rst1(5)
- rst2(5) = rst1.Fields(i).Name
- rst2(6) = rst1(i)
- Next
- rst2.Update
- rst2.MoveNext
- rst1.MoveNext
- Loop
- rst2.Close
- rst1.Close
- Msgbox "Done"
- End Sub
复制代码 3、按下F5执行即可,弹出提示后打开表2即可看到效果。不过,Access不应该这么玩的……估计又是“Excel后遗症”惹的祸。 |
|