2
    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ビットが問題であると確信しています。テーブル名が間違っている可能性があります。

4

1 に答える 1

3

The tables and/or fieldnames in your SQL query don't match your database structure.

This includes any value in the sTableName parameter.

Just check and make sure all the fields match exactly and you should find the culprit.

EDIT: Just noticed this in the SELECT part

    “ [“ & sTableName & “] “ & _

You shouldn't be referencing the whole table in the SELECT portion of your statement, what happens if you remove this line from the SQL statement?

于 2013-03-14T05:38:03.030 に答える