Home > Software engineering >  Problem error msg "The SELECT statement includes a reserved word or an argument name that is mi
Problem error msg "The SELECT statement includes a reserved word or an argument name that is mi

Time:04-11

My problem is: I get an error that appears in my code every time I run it and I don't know why; please I need your help.

When I run the query, it worked but when I tried to code it, I get ab error

The SELECT statement includes a reserved word or an argument name that is misspelled or missing , or the punctuation is incorrect

This is my code:

Sub Import_Cable_list()

Dim strSQL As String

strSQL = "SELECT SPI_query.Loop_name, Panel_from_ITR.PANEL_FROM, Cable_List_ITR.ITR AS ITR_Panel_FROM, Cable_List_ITR.[ITR State] AS ITR_State_Panel_FROM, PANEL_TO_ITR.PANEL_TO, PANEL_TO_ITR.ITR AS ITR_Panel_TO, PANEL_TO_ITR.[ITR State] AS ITR_State_Panel_TO, Cable_List_ITR.CABLE_NUM, Cable_List_ITR.ITR AS ITR_Cable_Number, Cable_List_ITR.[ITR State] AS ITR_State_Cable_Number, Jb_Cabinet.PANEL_TO AS Cabinet, Cable_List_ITR.ITR AS ITR_Cabinet, Cable_List_ITR.[ITR State] AS ITR_State_Cabinet" & _
         "FROM SPI_query INNER JOIN (((PANEL_TO_ITR INNER JOIN Panel_from_ITR ON PANEL_TO_ITR.PANEL_FROM = Panel_from_ITR.PANEL_FROM) INNER JOIN Cable_List_ITR ON Panel_from_ITR.PANEL_FROM = Cable_List_ITR.PANEL_FROM) INNER JOIN Jb_Cabinet ON Panel_from_ITR.PANEL_FROM = Jb_Cabinet.PANEL_FROM) ON SPI_query.Clean_Tag_Number = Panel_from_ITR.PANEL_FROM ; "

DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

End Sub

CodePudding user response:

Try adding a space:

strSQL = "SELECT SPI_query.Loop_name, Panel_from_ITR.PANEL_FROM, Cable_List_ITR.ITR AS ITR_Panel_FROM, Cable_List_ITR.[ITR State] AS ITR_State_Panel_FROM, PANEL_TO_ITR.PANEL_TO, PANEL_TO_ITR.ITR AS ITR_Panel_TO, PANEL_TO_ITR.[ITR State] AS ITR_State_Panel_TO, Cable_List_ITR.CABLE_NUM, Cable_List_ITR.ITR AS ITR_Cable_Number, Cable_List_ITR.[ITR State] AS ITR_State_Cable_Number, Jb_Cabinet.PANEL_TO AS Cabinet, Cable_List_ITR.ITR AS ITR_Cabinet, Cable_List_ITR.[ITR State] AS ITR_State_Cabinet " & _
         "FROM SPI_query INNER JOIN (((PANEL_TO_ITR INNER JOIN Panel_from_ITR ON PANEL_TO_ITR.PANEL_FROM = Panel_from_ITR.PANEL_FROM) INNER JOIN Cable_List_ITR ON Panel_from_ITR.PANEL_FROM = Cable_List_ITR.PANEL_FROM) INNER JOIN Jb_Cabinet ON Panel_from_ITR.PANEL_FROM = Jb_Cabinet.PANEL_FROM) ON SPI_query.Clean_Tag_Number = Panel_from_ITR.PANEL_FROM ; "

CodePudding user response:

Try to use this query

strSQL = "SELECT SPI_query.Loop_name,
 Panel_from_ITR.PANEL_FROM,
 Cable_List_ITR.ITR AS ITR_Panel_FROM,
 `Cable_List_ITR.ITR State` AS ITR_State_Panel_FROM,
 PANEL_TO_ITR.PANEL_TO,
 PANEL_TO_ITR.ITR AS ITR_Panel_TO,
 `PANEL_TO_ITR.ITR State` AS ITR_State_Panel_TO,
 Cable_List_ITR.CABLE_NUM,
 Cable_List_ITR.ITR AS ITR_Cable_Number,
 `Cable_List_ITR.ITR State` AS ITR_State_Cable_Number,
 Jb_Cabinet.PANEL_TO AS Cabinet,
 Cable_List_ITR.ITR AS ITR_Cabinet,
 `Cable_List_ITR.ITR State` AS ITR_State_Cabinet" & _
         "FROM SPI_query 
         INNER JOIN (
             (
                 (PANEL_TO_ITR INNER JOIN Panel_from_ITR ON PANEL_TO_ITR.PANEL_FROM = Panel_from_ITR.PANEL_FROM) 
                INNER JOIN Cable_List_ITR ON Panel_from_ITR.PANEL_FROM = Cable_List_ITR.PANEL_FROM
            ) 
        INNER JOIN Jb_Cabinet ON Panel_from_ITR.PANEL_FROM = Jb_Cabinet.PANEL_FROM
        ) 
        ON SPI_query.Clean_Tag_Number = Panel_from_ITR.PANEL_FROM ; "
  • Related