Re: Syntax error in FROM clause

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Chris2 (indanthrene.NOTVALID_at_GETRIDOF.yahoo.com)
Date: 03/18/04


Date: Thu, 18 Mar 2004 01:31:17 GMT


"antonette" <antonette658@hotmail.com> wrote in message
news:798ee48a.0403171140.65474a72@posting.google.com...
> Are there hidden characters added by Acess into queries?
>
> I am trying to return the sum of the [sell price] column created by a
> temporary table. I'm using Access 2000, Win2k, and generated the
> following syntax by using the design grid and typing into the SQL
> window:
>
> SELECT Sum([%$##@_Alias].sumsell) AS SumOfsumsell
> FROM [SELECT [Bangkok Purchase Order].[sell price] as sumsell,
> [Bangkok Purchase Order].bycore
> FROM [Bangkok Purchase Order]
> WHERE ((([Bangkok Purchase Order].poid)=58))
> GROUP BY [Bangkok Purchase Order].[sell price], [Bangkok Purchase
> Order].bycore]. AS [%$##@_Alias];
>

  SELECT Sum([%$##@_Alias].sumsell) AS SumOfsumsell
    FROM [SELECT [Bangkok Purchase Order].[sell price] as sumsell
                ,[Bangkok Purchase Order].bycore
            FROM [Bangkok Purchase Order]
           WHERE ((([Bangkok Purchase Order].poid)=58))
GROUP BY [Bangkok Purchase Order].[sell price]
        ,[Bangkok Purchase Order].bycore]. AS [%$##@_Alias];

Antonette,

  The derived table on the FROM clause (the SELECT statement written on the
FROM clause) does not appear to be closed, that is, there is a starting "[",
but no closing "]" at the end.

  I too would not use special characters on a Column-name alias (or spaces
in Column-names or Table-names, either).

  If I wrote it, it would look like this (I didn't alter names, because I
don't know that you can).
  Most changes are to "()" and "[]". I removed all the () around the single
WHERE clause criteria, and now there is a single pair of () around the
entire SELECT on the FROM clause.
  I also removed the "." that appeared in the GROUP BY clause.

  Note: This is not tested.

  SELECT Sum([%$##@_Alias].sumsell) AS SumOfsumsell
    FROM (SELECT [Bangkok Purchase Order].[sell price] as sumsell
                ,[Bangkok Purchase Order].bycore
            FROM [Bangkok Purchase Order]
           WHERE [Bangkok Purchase Order].poid = 58)
GROUP BY [Bangkok Purchase Order].[sell price]
        ,[Bangkok Purchase Order].bycore] AS [%$##@_Alias];

  The reason that you are getting an error upon editing a working query is
because Access has the wonderful habit of changing the "()" and "[]" in a
query against your will (and other things). It does this after a Query is
closed, and then the Query keeps working, but should the Query be Opened and
any part of it be edited, Access begins to throw fits by refusing to believe
its a working Query. I have no idea why this massive software flaw exists,
but it's there. If you need to go back and successfully change a Query that
Access has broken in this manner, you need to clean up Access's improper
changes (fixing the SQL manually, character by character), so that it's a
working and saveable Query again, and then proceed to make whatever changes
you need.

  Now you know why the Guru's of Access keep chanting, "No spaces or special
characters in Column or Table names." (Although avoiding their use will not
prevent this particular bug from striking: Using BETWEEN on the FROM clause,
and linking to Tables in other Databases by using a Path Name directly on
the FROM clause can both cause this error; sometimes the error is so severe
that you are not allowed back into the Query at all, at this point, you must
use the Visual Basic Editor to print out the SQL property in the Immediate
Window, delete the malfunctioning Query entirely, recreate it, and paste the
retrieved SQL back into it (and fixing it by hand, too, as mentioned above.
Oh, this is Access 2000 SP-3: I haven't seen the most severe form of this
bug, not being let back into the Query, since SP-1 and before.)

Sincerely,

Chris O.

> This returns the desired result. If I go back to it however, and
> simply add a space to the end of the first line and delete it, I get a
> "Syntax error in FROM clause" and it highlights the second FROM. All
> the text remains the same.
>
> Does anyone know what this could be? Or maybe there's better syntax I
> can use?
> Any help would be greatly appreciated!



Relevant Pages

  • Re: Using part of a field
    ... See the article "Finding and replacing characters using wildcards" at: ... AS400 SQL may have a different way of doing ... called i.dsn, containing the followiing text: ... sort of thing in a query. ...
    (microsoft.public.word.mailmerge.fields)
  • Re: export form filtered data to excel
    ... ' There's no ORDER BY in the SQL. ... ' Remove the semi-colon from the end, then append the WHERE clause ... Or, better yet, look at the actual SQL for your query and see what's ... Dim qdfTemp As DAO.QueryDef ...
    (microsoft.public.access.formscoding)
  • Re: Query to Count Duplicate Values in a Given Date Range
    ... Show" to note whether the client showed up at the pantry. ... Now, if I try to run the query with that field, it returns no results. ... Here's my final SQL code if you see anything else that may need adjusting. ... use a WHERE clause rather than HAVING for the dates, ...
    (microsoft.public.access.queries)
  • Re: Error: Specified field could refer to more than one table
    ... WeeklyMileage) in SELECT Clause my guess is that the reference exists ... Run the query and select Remove Filter/sort from the menu and then save the ... Copy the SQL text into a blank query and try switching into design view ... FROM clause of your SQL statement. ...
    (microsoft.public.access.queries)
  • Re: Error: Specified field could refer to more than one table
    ... WeeklyMileage) in SELECT Clause my guess is that the reference exists ... Run the query and select Remove Filter/sort from the menu and then save the ... Copy the SQL text into a blank query and try switching into design view ... FROM clause of your SQL statement. ...
    (microsoft.public.access.queries)