Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Unanswered: Union query and IF statement in Access

    Please bare with me as I am new to databases and programming.
    I am trying to create a daily report using several queries' results, via Union statement. I have no problems running the UNION SELECT below. But when I add the IF..Then.. statement I recieve an error message of "Syntax error in FROM clause". Can someone please point out were I am screwing this thing up???? Thanks in advance.....


    SELECT Count (*) AS Records
    FROM qry_DER_I_1
    UNION SELECT Count(*) FROM qry_DER_I_2
    UNION SELECT Count(*) FROM qry_DER_I_3
    UNION SELECT Count(*) FROM qry_DER_I_2
    UNION SELECT Count(*) FROM qry_DER_I_4
    UNION SELECT Count(*) FROM qry_DER_I_5
    UNION SELECT Count(*) FROM qry_DER_I_6
    UNION SELECT Count(*) FROM qry_DER_I_7
    UNION SELECT Count(*) FROM qry_DER_I_8
    UNION SELECT Count(*) FROM qry_DER_I_9
    UNION SELECT Count(*) FROM qry_DER_I_10
    UNION SELECT Count(*) FROM qry_DER_I_11
    UNION SELECT Count(*) FROM qry_DER_I_12
    UNION SELECT Count(*) FROM qry_DER_I_13
    UNION SELECT Count(*) FROM qry_DER_II_1
    UNION SELECT Count(*) FROM qry_DER_II_2
    UNION SELECT Count(*) FROM qry_DER_II_3
    UNION SELECT Count(*) FROM qry_DER_II_2
    UNION SELECT Count(*) FROM qry_DER_II_4
    UNION SELECT Count(*) FROM qry_DER_II_5
    UNION SELECT Count(*) FROM qry_DER_II_6
    UNION SELECT Count(*) FROM qry_DER_II_7
    UNION SELECT Count(*) FROM qry_DER_II_8
    UNION SELECT Count(*) FROM qry_DER_II_9
    UNION SELECT Count(*) FROM qry_DER_II_10
    UNION SELECT Count(*) FROM qry_DER_II_11
    UNION SELECT Count(*) FROM qry_DER_II_12
    UNION SELECT Count(*) FROM qry_DER_II_13
    UNION SELECT Count(*) FROM qry_DER_II_14
    UNION SELECT Count(*) FROM qry_DER_II_15
    UNION SELECT Count(*) FROM qry_DER_II_16
    UNION SELECT Count(*) FROM qry_DER_II_17
    UNION SELECT Count(*) FROM qry_DER_II_18
    UNION SELECT Count(*) FROM qry_DER_II_19
    UNION SELECT Count(*) FROM qry_DER_II_20
    UNION SELECT Count(*) FROM qry_DER_II_21
    UNION SELECT Count(*) FROM qry_DER_II_22
    UNION SELECT Count(*) FROM qry_DER_II_23
    IF Records IsNull THEN 'N/A'
    ELSE default_result
    END;

  2. #2
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: Union query and IF statement in Access

    Originally posted by ixo151
    Please bare with me as I am new to databases and programming.
    I am trying to create a daily report using several queries' results, via Union statement. I have no problems running the UNION SELECT below. But when I add the IF..Then.. statement I recieve an error message of "Syntax error in FROM clause". Can someone please point out were I am screwing this thing up???? Thanks in advance.....


    SELECT Count (*) AS Records
    FROM qry_DER_I_1
    UNION SELECT Count(*) FROM qry_DER_I_2
    UNION SELECT Count(*) FROM qry_DER_I_3
    UNION SELECT Count(*) FROM qry_DER_I_2
    UNION SELECT Count(*) FROM qry_DER_I_4
    UNION SELECT Count(*) FROM qry_DER_I_5
    UNION SELECT Count(*) FROM qry_DER_I_6
    UNION SELECT Count(*) FROM qry_DER_I_7
    UNION SELECT Count(*) FROM qry_DER_I_8
    UNION SELECT Count(*) FROM qry_DER_I_9
    UNION SELECT Count(*) FROM qry_DER_I_10
    UNION SELECT Count(*) FROM qry_DER_I_11
    UNION SELECT Count(*) FROM qry_DER_I_12
    UNION SELECT Count(*) FROM qry_DER_I_13
    UNION SELECT Count(*) FROM qry_DER_II_1
    UNION SELECT Count(*) FROM qry_DER_II_2
    UNION SELECT Count(*) FROM qry_DER_II_3
    UNION SELECT Count(*) FROM qry_DER_II_2
    UNION SELECT Count(*) FROM qry_DER_II_4
    UNION SELECT Count(*) FROM qry_DER_II_5
    UNION SELECT Count(*) FROM qry_DER_II_6
    UNION SELECT Count(*) FROM qry_DER_II_7
    UNION SELECT Count(*) FROM qry_DER_II_8
    UNION SELECT Count(*) FROM qry_DER_II_9
    UNION SELECT Count(*) FROM qry_DER_II_10
    UNION SELECT Count(*) FROM qry_DER_II_11
    UNION SELECT Count(*) FROM qry_DER_II_12
    UNION SELECT Count(*) FROM qry_DER_II_13
    UNION SELECT Count(*) FROM qry_DER_II_14
    UNION SELECT Count(*) FROM qry_DER_II_15
    UNION SELECT Count(*) FROM qry_DER_II_16
    UNION SELECT Count(*) FROM qry_DER_II_17
    UNION SELECT Count(*) FROM qry_DER_II_18
    UNION SELECT Count(*) FROM qry_DER_II_19
    UNION SELECT Count(*) FROM qry_DER_II_20
    UNION SELECT Count(*) FROM qry_DER_II_21
    UNION SELECT Count(*) FROM qry_DER_II_22
    UNION SELECT Count(*) FROM qry_DER_II_23
    IF Records IsNull THEN 'N/A'
    ELSE default_result
    END;
    From the help files:

    IsNull Function

    Returns a Boolean value that indicates whether an expression contains no valid data (Null).

    Syntax

    IsNull(expression)

    The required expression argument is a Variant containing a numeric expression or string expression.

    Gregg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •