I want to copy a SQL string from a query I created into a Variable string in Access, but when I try to run the SQL string I get an error. My query has a lot of inner joins and is complex, and I am guessing that the syntax for VBA SQL is not the same as the SQL Statement in the Query window. Can someone please look at my select and tell me how I can fix it so that it will run in VBA. (The tables that start with SQ_ is that it is calling that information from another query.)
SELECT T_Tickets.TicketID, T_Categories.TicketCategory, T_Employees.USERNAME AS [User], T_DEPARTMENTS.DEPARTMENT, T_Tickets.Issue, T_Tickets.Resolution, T_Tickets.Materials, T_Tickets.StartDate, T_Tickets.CompleteDate, T_CompletionTime.CompletionTime, SQ_AssignID.USERNAME AS Assigned, SQ_CompleteID.USERNAME AS CompletedBy
FROM ((T_DEPARTMENTS INNER JOIN (T_CompletionTime INNER JOIN (T_Employees INNER JOIN (T_Categories INNER JOIN T_Tickets ON T_Categories.CategoryID = T_Tickets.CategoryID) ON T_Employees.USERID = T_Tickets.UserID) ON T_CompletionTime.TimeID = T_Tickets.TimeID) ON T_DEPARTMENTS.DEPTID = T_Employees.USERDEPT) INNER JOIN SQ_AssignID ON T_Tickets.TicketID = SQ_AssignID.TicketID) INNER JOIN SQ_CompleteID ON T_Tickets.TicketID = SQ_CompleteID.TicketID;
SELECT T_Tickets.TicketID, T_Categories.TicketCategory, T_Employees.USERNAME AS [User], T_DEPARTMENTS.DEPARTMENT, T_Tickets.Issue, T_Tickets.Resolution, T_Tickets.Materials, T_Tickets.StartDate, T_Tickets.CompleteDate, T_CompletionTime.CompletionTime, SQ_AssignID.USERNAME AS Assigned, SQ_CompleteID.USERNAME AS CompletedBy
FROM ((T_DEPARTMENTS INNER JOIN (T_CompletionTime INNER JOIN (T_Employees INNER JOIN (T_Categories INNER JOIN T_Tickets ON T_Categories.CategoryID = T_Tickets.CategoryID) ON T_Employees.USERID = T_Tickets.UserID) ON T_CompletionTime.TimeID = T_Tickets.TimeID) ON T_DEPARTMENTS.DEPTID = T_Employees.USERDEPT) INNER JOIN SQ_AssignID ON T_Tickets.TicketID = SQ_AssignID.TicketID) INNER JOIN SQ_CompleteID ON T_Tickets.TicketID = SQ_CompleteID.TicketID;