Results 1 to 4 of 4
  1. #1
    adibob2005 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    2

    Union Query - Is there any function like 'IF EXIST' ?

    I am using a union query in for combining results from 2 linked tables as under:

    SELECT * FROM TABLE1


    UNION
    SELECT * FROM TABLE2;

    Now, I want that even if one of the table does not exist, the query should work i.e. it should return results from only one table.

    Is there any function like 'IF EXIST' ?
    Please help.
    Regards

  2. #2
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    ... even if one of the table does not exist ...
    If a table does not exist, your users will get an error message.
    IF EXISTS is available with TSQL (SQL Server) but I could not find any reference to it in Access 2007 Help. Even then, EXISTS tests whether any records or value is returned, NOT if a table exists.

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by adibob2005 View Post
    I am using a union query in for combining results from 2 linked tables as under:

    SELECT * FROM TABLE1
    UNION
    SELECT * FROM TABLE2;

    Now, I want that even if one of the table does not exist, the query should work i.e. it should return results from only one table.
    do it in a form. write a vba conditional to execute either sql code or query objects, based on the existence. it's that simple.

  4. #4
    adibob2005 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    2

    please explain

    Quote Originally Posted by ajetrumpet View Post
    do it in a form. write a vba conditional to execute either sql code or query objects, based on the existence. it's that simple.
    Can you explain it to me as I have never done VBA programming ?.
    Please provide a sample code.

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

Similar Threads

  1. Date function within a Union Query
    By pmplyons in forum Programming
    Replies: 2
    Last Post: 08-24-2011, 11:33 AM
  2. Help with a Union Query
    By Bear in forum Queries
    Replies: 12
    Last Post: 08-14-2011, 05:12 PM
  3. Union Query
    By jlclark4 in forum Queries
    Replies: 3
    Last Post: 02-25-2011, 08:21 PM
  4. Please help me out with union query
    By radicrains in forum Access
    Replies: 1
    Last Post: 10-29-2010, 01:48 AM
  5. Query: How many times does a value exist?
    By hognabbt in forum Queries
    Replies: 1
    Last Post: 01-10-2010, 01:33 PM

Tags for this Thread

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