Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query gives error if any keyboard key is touched while in SQL mode 2

Status
Not open for further replies.

netrusher

Technical User
Joined
Feb 13, 2005
Messages
952
Location
US
Below is the code I currently have as a query. This query
works fine util: If I go into SQL mode and make any changes
at all I get an error. If I add a linefeed and take it back
out, I still get this error. If I change any character and
then change it back to exactly what it was I still get this
error:

Invalid bracketing of name 'SELECT vTbl.Day
as WUDay, Count(*) AS [WU Totals'

This only happens if I hit any key of any kind. This seems
really weird that the SQL will work as long as I do not
hit any keys in SQL mode. Any advice out here? Can someone
tell me what Bracketing I should change?

Code:
SELECT Format(TodaysDate,'yyyy-mm-dd') AS [Date], WU.[WU Totals], Count(*) AS [Leak Totals], (Count(*)/WU.[WU Totals]*1) AS [Percent]
FROM WorkUnitsFaultsMainTBL, [SELECT vTbl.Day as WUDay,
              Count(*) AS [WU Totals]
       FROM
             (SELECT DISTINCT Format(TodaysDate,'yyyy-mm-dd') AS [Day], WorkUnit
              FROM WorkUnitsFaultsMainTBL
              WHERE BuildID IN ('E010','C809','F001','C810','F187','A910','M173','M174')
               AND (TodaysDate BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt] 
                                    And [Forms]![Queries_ReportsFRM]![EndDateTxt])) AS vTbl
       GROUP BY vTbl.Day ]. AS WU
WHERE (((WorkUnitsFaultsMainTBL.Problem) Like "*leak*") AND ((WorkUnitsFaultsMainTBL.TodaysDate) Between [Forms]![Queries_ReportsFRM]![StartDateTxt] And [Forms]![Queries_ReportsFRM]![EndDateTxt]) AND ((WorkUnitsFaultsMainTBL.BuildID) In ("E010","C809","F001","C810","F187","A910","M173","M174")) AND ((Format([TodaysDate],'yyyy-mm-dd'))=[WU].[WUDay]))
GROUP BY Format(TodaysDate,'yyyy-mm-dd'), WU.[WU Totals]
ORDER BY Format(TodaysDate,'yyyy-mm-dd'), WU.[WU Totals], Count(*) DESC;
 
try
Code:
CODE
SELECT Format(TodaysDate,'yyyy-mm-dd') AS [Date], WU.[WU Totals], Count(*) AS [Leak Totals], (Count(*)/WU.[WU Totals]*1) AS [Percent]
FROM WorkUnitsFaultsMainTBL, (SELECT vTbl.Day as WUDay,
              Count(*) AS [WU Totals]
       FROM
             (SELECT DISTINCT Format(TodaysDate,'yyyy-mm-dd') AS [Day], WorkUnit
              FROM WorkUnitsFaultsMainTBL
              WHERE BuildID IN ('E010','C809','F001','C810','F187','A910','M173','M174')
               AND (TodaysDate BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt] 
                                    And [Forms]![Queries_ReportsFRM]![EndDateTxt])) AS vTbl
       GROUP BY vTbl.Day ) AS WU
WHERE (((WorkUnitsFaultsMainTBL.Problem) Like "*leak*") AND ((WorkUnitsFaultsMainTBL.TodaysDate) Between [Forms]![Queries_ReportsFRM]![StartDateTxt] And [Forms]![Queries_ReportsFRM]![EndDateTxt]) AND ((WorkUnitsFaultsMainTBL.BuildID) In ("E010","C809","F001","C810","F187","A910","M173","M174")) AND ((Format([TodaysDate],'yyyy-mm-dd'))=[WU].[WUDay]))
GROUP BY Format(TodaysDate,'yyyy-mm-dd'), WU.[WU Totals]
ORDER BY Format(TodaysDate,'yyyy-mm-dd'), WU.[WU Totals], Count(*) DESC;
 
Thanks pwise,

What did you change and why so I can learn?
 
instead of [brackets] around the subquery i put (presentences)

i think that if you put this in to design view you might get the same error
 
In Access query designer, the notation [red][ ... ].[/red] is used for some types of clauses. Query designer has (in my opinion at least) a flaw where it substitutes that notatiion for parentheses around a sub-query. As long as you don't change anything after that substitution, everything works fine. If you change anything in the statement then it re-parses the SQL and decides that the [red][...].[/red] notation is invalid.

The "cure" is to change [red][...].[/red] back to [red](...)[/red].
 
very nicely put

have a Star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top