Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2009
    Posts
    39

    Question Unanswered: Running a query on a query?

    I'm trying to figure out why Access won't let me run a query (query1) on another query(query2).

    Query1 worked for the table that query2 is based on.

    All query2 is is a 2 tables joined together (Product Information table Joined with the Customer table).

    But every time I try and run it, I get an error in the FROM clause.

    "Syntax error in FROM clause"

    Anyone know why this is? I know I've ran queries on other queries before and it ran so this is quite confusing.

    Thanks!

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Hard to say without seeing the SQL of the query.
    Paul

  3. #3
    Join Date
    Jul 2009
    Posts
    39
    SELECT month(EndDate) AS [Month], year(EndDate) AS [Year]
    FROM query2
    WHERE month(EndDate)=[Enter Month] And year(EndDate)=[Enter Year];

    I get that error from this.

  4. #4
    Join Date
    Jul 2009
    Posts
    39
    This is what query2 is composed of
    ----------------------------
    SELECT tblCustomer.Company, tblCustomer.FirstName, tblCustomer.LastName, tblCustomer.Phone, tblCustomer.Email, tblProducts.User, tblProducts.Product, tblProducts.StartDate, tblProducts.EndDate, tblProducts.AmountPaid, tblProducts.Comments
    FROM tblCustomer INNER JOIN tblProducts ON tblCustomer.ID=tblProducts.ContactID;

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    query2 runs without error on its own? I don't see anything wrong with that SQL. Can you post the db here?
    Paul

  6. #6
    Join Date
    Jul 2009
    Posts
    39
    Yes query2 runs fine on its own without error.

    And yes it looks good to me which is why it's so confusing.

    And here it is.

    query2 is called qrySubByCompany(raw) (Slightly abbreviated)

    query1 is called qryEndDate

    The query currently has the table in place of the query just to show you that it works. But when you replace it with query 2, you get the error.
    Attached Files Attached Files

  7. #7
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    qryEndDate runs without error for me. After prompting for month and year, it displays a record. It still runs if I change the source to the query instead of the table.
    Paul

  8. #8
    Join Date
    Jul 2009
    Posts
    39
    Really? What the hell is going on then? Can you reupload that database for me then?

    You think there might be a discrepancy with the versions of Access we're using? Because I'm using Office 2007.

    That's really weird.

  9. #9
    Join Date
    Jul 2009
    Posts
    39
    I figured it out, I needed to place square brackets, [] around the query.

Posting Permissions

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