Results 1 to 9 of 9
  1. #1
    scotty22 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    29

    Can't open query

    Hi there,



    I have been using a union query fine, and just randomly it prevents me from opening it...even in design view!!!

    If I try to open it as a datasheet, I get the message 'Query input must contain at least one table or query', and if I try to open it in design view I get 'The search key was not found in any record'.

    Any ideas?

    Kind regards,

    Scotty22

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,170
    Hi Scotty,

    it's normal you can't open a union query in design view; However it should always open in SQL view. have you tried that?

    grNG

  3. #3
    scotty22 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    29
    I cannot even open it in SQL view.

  4. #4
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,170
    Hi,

    do you know what SQL statement it should contain?
    What's the different in your database the times you can open it and the times you can't. Is it possible there are some linked tables/datasources in your database that aren't always available?

    grNG

  5. #5
    scotty22 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    29
    It's a union query of 15 other queries and selects all columns each time i.e. SELECT * FROM....UNION SELECT * FROM.....etc (and I can open all of these fine).

    The only thing I did before I tried opening it, was I changed a string text in one of the excel spreadsheets, which is linked.

    Any more thoughts?

  6. #6
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,170
    Hi,

    the select * is useful, but can be dangerous.
    If in one of the datasources a column is added or removed, or in the Excel file a text was entered in a numeric or date column that's enough to trigger an error.
    In an union query all datasources have to have exact the same number of columns, and all data types of all columns should match.

    grNG

  7. #7
    scotty22 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    29
    Noted. I just find * much easier on the eyes. I still can't open the query though and I've tried compacting and repairing...

  8. #8
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,170
    Hi,

    I'm afraid the best you can do is pick the last working version up from a back-up file, or start to rewrite the union query peace by peace. I would start writing the first line select * from X union select * from Y, try it out, if it works add another statement, try it out ect. till you find out the line that gives the eroor.

    Good luck
    NG

  9. #9
    scotty22 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    29
    Just redid it and it works fine. I suppose maybe the query itself got damaged? I don't really know enough about the programming behind Access so I'll leave that one with the experts.

    Thanks a bunch

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

Similar Threads

  1. How to open a query in a form
    By Need_Help in forum Forms
    Replies: 5
    Last Post: 07-01-2011, 01:47 PM
  2. Use query result to open form.
    By Playerpawn in forum Access
    Replies: 3
    Last Post: 05-12-2011, 11:18 PM
  3. Replies: 29
    Last Post: 02-13-2011, 01:21 AM
  4. Open a query
    By zhshqzyc in forum Programming
    Replies: 1
    Last Post: 01-25-2011, 12:56 PM
  5. Open Query from another database
    By thestappa in forum Programming
    Replies: 2
    Last Post: 07-23-2010, 08:45 AM

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