点击下载此附件
给你回复的示例中增加了一个窗体1,上面有个行列转换的按钮,你可以先将“转换后需要的结果”表中的数据删除,然后测试一下。
Dim rst1 As Object
Dim rst2 As Object
Dim strSQL1 As String
Dim strSQL2 As String
Set rst1 = CreateObject("adodb.recordset")
Set rst2 = CreateObject("adodb.recordset")
strSQL1 = "select A,B,C,D from 原数据表 where 条目 = '数量'"
strSQL2 = "select * from 转换后需要的结果"
rst1.Open strSQL1, CurrentProject.Connection, 1, 1
rst2.Open strSQL2, CurrentProject.Connection, 1, 3
For J = 0 To rst1.Fields.Count - 1
'MsgBox rst1.Fields(J).Name
rst2.AddNew
rst2!条目 = rst1.Fields(J).Name
rst2!数量 = rst1.Fields(J).Value
rst2.Update
Next
rst1.Close
rst2.Close
Set rst1 = Nothing
Set rst2 = Nothing
MsgBox "转换完成!"