Private Sub createSequenceDataFiles_Sequence(sPath As String, sTableName As String, iSeqNo As Integer)
Dim RST As DAO.Recordset
Dim nIL As Long, nLastIL As Long
Dim sSQL As String
'
' Get the data from the table
'
sSQL = _
" SELECT [“ & sTableName & “].IL, “ & _
“ [XL]-[FIRST_XL]+1 AS XL_IDX, “ & _
“ [“ & sTableName & “] “ & _
“ FROM [“ & sTableName & “] “ & _
“ INNER JOIN TBL_FIRST_XL_FOR_IL “ & _
“ ON [“ & sTableName & “].IL = TBL_FIRST_XL_FOR_IL.IL “ & _
“ ORDER BY [“ & sTableName & ”].IL, [XL]-[FIRST_XL]+1”
Set RST = CurrentDb.OpenRecordset(sSQL)
While Not RST.EOF
nIL = RST("IL").Value
If Not (nLastIL = nIL) Then
'
' If we've already done one, close the file
'
If nLastIL > 0 Then Close #1
'
' Open the file for the current in-line
'
Open sPath & "\WBS1\IL_" & Format(nIL, "0000") & ".pks" For Append As 1
End If
'
' Write the data
'
Write #1, iSeqNo, RST(“XL_IDX”).value + 1, RST("TIME").Value
nLastIL = nIL
RST.MoveNext
Wend
'
' Close
'
Set RST = Nothing
Close
End Sub
我收到此错误
这有什么问题吗?
这是整个代码现在我很确定它是SQL位,这是问题,也许我的表名错了。
答案 0 :(得分:4)
SQL查询中的表和/或字段名与数据库结构不匹配。
这包括sTableName
参数中的任何值。
只需检查并确保所有字段完全匹配,您就应该找到罪魁祸首。
编辑:刚刚在SELECT部分中注意到了这一点
“ [“ & sTableName & “] “ & _
您不应该在语句的SELECT
部分引用整个表,如果从SQL语句中删除此行会发生什么?