|
这是我的程序,cellarray(0,l) 是列名,每次循环把一列数字写入相应的列名中。
运行结束后,列名创建没有问题,debug显示每次插入前,cellarray(0,l)的值也都是正确的,但是结果就是全都插入第一列
求帮助啊!!!
For l = LBound(CellArray, 2) To UBound(CellArray, 2)
SQL = "alter table ExportData add COLUMN " & CellArray(0, l) & " text(15)"
DoCmd.RunSQL SQL
CellCode = CellArray(0, l)
SQL = "select utranRelationId from UtranRelation where utranCellId =" & """" & CellArray(0, l) & """"
Set rs = CurrentDb.OpenRecordset(SQL)
With rs
If Not .EOF Then
.MoveLast
.MoveFirst
End If
NrTempArray = rs.GetRows(.RecordCount)
.Close
End With
For m = LBound(NrTempArray, 2) To UBound(NrTempArray, 2)
NrList(l, m) = NrTempArray(0, m)
SQL = "insert into ExportData(" & CellArray(0, l) & ") values('" & NrTempArray(0, m) & "')"
DoCmd.RunSQL SQL
Next m
'write to table
NrNo(l) = m
For i = 0 To m
CellCode = NrList(l, i)
SQL = "insert into ExportData(" & CellArray(0, l) & ") values('" & CellCode & "')"
DoCmd.RunSQL SQL
'Debug.Print CellArray(0, l)
Next i
Next l
End Sub |
|