Hi
I'm fairly new to VBA in Access. I want to run a Query using :
DoCmd.RunSQL SQL_text
However I'm experiencing problems in generating the SQL_text variable. The problem is related to the SQL code. I read some articles about it and I tried to apply that knowledge. Unfortunately, with no success. Please could you help me figure out what did I do wrong. My SQL_text variable is defined as:
SQL_text = "SELECT [Step9: Renaming Comment columns].[Target Region], [Step9: Renaming Comment columns].[Payroll Region], [Step9: Renaming Comment columns].Business_Unit, [Step9: Renaming Comment columns].[BU RPT], [Step9: Renaming Comment columns].[Sales Org BU], [Step9: Renaming Comment columns].[Sales Specialty Code], [Step9: Renaming Comment columns].[Sales Title], [Step9: Renaming Comment columns].[Employee Name (Last, First)], [Step9: Renaming Comment columns].[Employee ID], [Step9: Renaming Comment columns].[Manager Name (Last, First)], [Step9: Renaming Comment columns].[Manager Employee Number], [Step9: Renaming Comment columns].[Mail sent to Mgr (dd-mm-yy)], " & _
"[Step9: Renaming Comment columns].[Handled By], [Step9: Renaming Comment columns].[Manager Notification Sent], [Step9: Renaming Comment columns].[Manager Notification Sentdate], [Step9: Renaming Comment columns].[Days Outstanding], [Step9: Renaming Comment columns].[Generation Date2] AS [Generation Date], [Step9: Renaming Comment columns].[Letter Issue Date], [Step9: Renaming Comment columns].[Viewed Date], [Step9: Renaming Comment columns].[Letter Passively Approved (dd-mm-yy)], [Step9: Renaming Comment columns].[Accepted Date], [Step9: Renaming Comment columns].[Reject Reason], [Step9: Renaming Comment columns].[Quest CL Status]" & _
", [Step9: Renaming Comment columns].[CEE CL Status], [Step9: Renaming Comment columns].[Measurement Period], [Step9: Renaming Comment columns].[Emp Status Code], [Step9: Renaming Comment columns].[SalesLetter Employee#Active Flag] AS [Sales Letter Employee Active Flag], [Step9: Renaming Comment columns].[Block View By Manager], IIf([Generation Date] Is Null,[Why not Created],'') AS [Why not Generated], IIf([Generation Date] Is Null,[Other Comment for not Created],'') " & _
"AS [Other Comment for not Generated], IIf([Quest CL Status]='Escalated',[What action taken against Escalation],'') AS [What actions taken against Escalation], IIf([CEE CL Status]='Generated' And [Quest CL Status]<>'Accepted' And [Quest CL Status]<>'Escalated',[Why not Accepted2],'') AS [Why not Accepted]" & _
"FROM [Step9: Renaming Comment columns] LEFT JOIN [FY11 H1 CEE Comments Table] ON [Step9: Renaming Comment columns].[Employee ID] = [FY11 H1 CEE Comments Table].[Employee ID];"
The code crushes and displays a Run time error 2342 "A RunSQL action requires an argument consisting of an SQL statement
I'm fairly new to VBA in Access. I want to run a Query using :
DoCmd.RunSQL SQL_text
However I'm experiencing problems in generating the SQL_text variable. The problem is related to the SQL code. I read some articles about it and I tried to apply that knowledge. Unfortunately, with no success. Please could you help me figure out what did I do wrong. My SQL_text variable is defined as:
SQL_text = "SELECT [Step9: Renaming Comment columns].[Target Region], [Step9: Renaming Comment columns].[Payroll Region], [Step9: Renaming Comment columns].Business_Unit, [Step9: Renaming Comment columns].[BU RPT], [Step9: Renaming Comment columns].[Sales Org BU], [Step9: Renaming Comment columns].[Sales Specialty Code], [Step9: Renaming Comment columns].[Sales Title], [Step9: Renaming Comment columns].[Employee Name (Last, First)], [Step9: Renaming Comment columns].[Employee ID], [Step9: Renaming Comment columns].[Manager Name (Last, First)], [Step9: Renaming Comment columns].[Manager Employee Number], [Step9: Renaming Comment columns].[Mail sent to Mgr (dd-mm-yy)], " & _
"[Step9: Renaming Comment columns].[Handled By], [Step9: Renaming Comment columns].[Manager Notification Sent], [Step9: Renaming Comment columns].[Manager Notification Sentdate], [Step9: Renaming Comment columns].[Days Outstanding], [Step9: Renaming Comment columns].[Generation Date2] AS [Generation Date], [Step9: Renaming Comment columns].[Letter Issue Date], [Step9: Renaming Comment columns].[Viewed Date], [Step9: Renaming Comment columns].[Letter Passively Approved (dd-mm-yy)], [Step9: Renaming Comment columns].[Accepted Date], [Step9: Renaming Comment columns].[Reject Reason], [Step9: Renaming Comment columns].[Quest CL Status]" & _
", [Step9: Renaming Comment columns].[CEE CL Status], [Step9: Renaming Comment columns].[Measurement Period], [Step9: Renaming Comment columns].[Emp Status Code], [Step9: Renaming Comment columns].[SalesLetter Employee#Active Flag] AS [Sales Letter Employee Active Flag], [Step9: Renaming Comment columns].[Block View By Manager], IIf([Generation Date] Is Null,[Why not Created],'') AS [Why not Generated], IIf([Generation Date] Is Null,[Other Comment for not Created],'') " & _
"AS [Other Comment for not Generated], IIf([Quest CL Status]='Escalated',[What action taken against Escalation],'') AS [What actions taken against Escalation], IIf([CEE CL Status]='Generated' And [Quest CL Status]<>'Accepted' And [Quest CL Status]<>'Escalated',[Why not Accepted2],'') AS [Why not Accepted]" & _
"FROM [Step9: Renaming Comment columns] LEFT JOIN [FY11 H1 CEE Comments Table] ON [Step9: Renaming Comment columns].[Employee ID] = [FY11 H1 CEE Comments Table].[Employee ID];"
The code crushes and displays a Run time error 2342 "A RunSQL action requires an argument consisting of an SQL statement