我有以下代码;
Dim tbloutput As DAO.Recordset
Dim i As Integer
Dim v As String
Set tbloutput = dbLocal.OpenRecordset("tbl_temp_forecast")
For i = 38 To 52
v = CStr(i)
.Cells(Rowindex, Columnindex).Value = tbloutput![v]
Columnindex = Columnindex + 1
v = ""
Next
我遇到的问题是当我尝试引用tbloutput时![COLUMN NAME]我想使用v或i的值,但是简单的tbloutput![i]或tbloutput![v]不起作用。
你可以就此提出建议吗?由于
答案 0 :(得分:1)
您的代码中有一个小的更正。
Dim tbloutput作为DAO.Recordset Dim i As Integer Dim v As String 设置tbloutput = dbLocal.OpenRecordset(" tbl_temp_forecast")
For i = 38 To 52
v = CStr(i)
.Cells(Rowindex, Columnindex).Value = "tbloutput![" & v & "]"
Columnindex = Columnindex + 1
v = ""
Next
让我知道这是否有效......