Dim rs1 As New ADODB.Recordset, rs2 As New ADODB.Recordset
Dim oldtbname As String
Dim newtbname As String
Dim i As Long, j As Long
oldtbname = "Project Total"
newtbname = "Project Total2"
rs1.Open oldtbname, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs2.Open newtbname, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
For i = 1 To rs1.RecordCount
For j = 6 To rs1.Fields.Count - 1
rs2.AddNew
rs2!Project_Owner.Value = rs1!Project_Owner.Value
rs2!Project_Manager.Value = rs1!Project_Manager.Value
rs2!Client_Name.Value = rs1!Client_Name.Value
rs2!Client_Type.Value = rs1!Client_Type.Value
rs2!Project.Value = rs1!Project.Value
rs2!Month.Value = rs1!Month.Value
rs2!类别.Value = rs1.Fields(j).Name
rs2!数值.Value = rs1.Fields(j).Value
rs2.Update
Next
rs1.MoveNext
Next
rs1.Close: Set rs1 = Nothing
rs2.Close: Set rs2 = Nothing
作者: todaynew 时间: 2015-1-15 19:12
检查表名称是否不正确,如果正确,最好用方括号将表名称括起来,以消除非法字符的影响。作者: tmtony 时间: 2015-1-15 23:23
可能是有关键字 保留字
以下来自MSDN,看来您的表名用了关键词,可以用[]包含起来来解决
SYMPTOMS
When opening a Microsoft Jet table using ActiveX Data Objects (ADO), the program displays the following error:
Run-time error '-2147217900 (80040e14)':
[Microsoft][ODBC Microsoft Access 97 Driver] Syntax error in FROM
clause.
CAUSE
The table name is a SQL reserved word, such as "Order".
RESOLUTION
Change the table name to a non-reserved word, such as "Orders" or place square brackets around the name: "[Order]"