Results 1 to 4 of 4
  1. #1
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295

    Talking Access change my query and then can't open it

    I created following query in SQL view:


    Code:
    SELECT a.customer, b.customer
        FROM Orders AS a LEFT JOIN 
     
        (select customer from orders WHERE stuff="Turkey" AND 
       Year([orderdate])=2010) AS b 
     
      ON a.customer = b.customer
    
       WHERE (((a.stuff)="Turkey") AND ((Year([a].[orderdate]))=2009) AND ((b.customer) Is Null));
    Then I save and close it. When I open again, it was changed to ("()" has been change to "[]."):
    Code:
    SELECT a.customer, b.customer
        FROM Orders AS a LEFT JOIN 
     
        [select customer from orders WHERE stuff="Turkey" AND 
       Year([orderdate])=2010]. AS b 
     
      ON a.customer = b.customer
    
       WHERE (((a.stuff)="Turkey") AND ((Year([a].[orderdate]))=2009) AND ((b.customer) Is Null));
    then, I have met these cases(sort from the best to the worst):
    1 I close the query without any changing, it works fine;
    2 I change something in the SQL view, save and close, it works fine;
    3 I change something in the SQL view, but can't not save because of some error of JOIN, after I changed the []. to (), I can save and it works;
    4 I change something in the SQL view, save and close, but it doesn't work because syntax error;
    5 The query doesn't work because of "Syntax error in FROM clause", I need to modify it;
    6 The query doesn't work because of "Syntax error in FROM clause", I can't open in design view because of "Syntax error in FROM clause"

    Now I am in case 6, I can't modify it because I can't not design it. What shall I do? Is there a way to open directly in SQL view?

  2. #2
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    Two things to try:

    1. Create a new empty database. Use File... Get External Data... Import to
    import this query into the new database. Can you see it then? It might allow the query to work.

    2. Type Ctrl-G to open the VBA editor and the Immediate window and type

    Application.SaveAsText "queryname", "C:\My Documents\foldername\xyz.txt"

    Open it in Notepad or something just to see if your SQL is still correct or not.
    Last edited by Rixxe; 10-14-2010 at 09:23 AM. Reason: Detail

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I imported, it remained not working.
    Application.SaveAsText get me the SQL.

    Thank you Rixxe.

    Is there any way to provent this error? Because it always happen and I need to modify it frequently.

  4. #4
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    As far as im aware, its a bug with Access.
    I have had it happen to me a number of times, if you do find a way of stopping it happening let me know!

    Cheers

    Rixxe

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query to change all data
    By justinwright in forum Queries
    Replies: 18
    Last Post: 09-01-2010, 08:41 AM
  2. % Change by Month in a Cross-tab Query
    By William McKinley in forum Queries
    Replies: 0
    Last Post: 07-10-2010, 11:45 AM
  3. Replies: 1
    Last Post: 06-09-2010, 04:19 PM
  4. Replies: 1
    Last Post: 06-04-2009, 07:43 AM
  5. Change to Form Closes Access
    By jbhjm in forum Forms
    Replies: 5
    Last Post: 04-22-2009, 01:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums