Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011

    Unanswered: Syntax error, two inner joins.

    I want to run an append query in VBA code. When trying to run the sql statements I made I always got "Syntax error in join operation" errors, therefore I tried making a query and "sub"query through access. Which worked.

    But I still have problems when I try to replace the "sub"query with the sql code from the other query (added () around it). I need the entire sql statement to run it with VBA code so I cannot just execute the stored query(going to use values from a form) so I would appreciate it if someone could help me.

    Here are the two queries which work but should be added together to one sql statement. QueryA uses QueryB.

    INSERT INTO tblTmpUseRelations ( Plant, RequestName )
    SELECT DISTINCT QueryB.Plant_forsyn, QueryB.RequestName
    FROM QueryB LEFT JOIN tblPlants ON QueryB.Plant_forsyn = tblPlants.Plant
    WHERE (((tblPlants.Plant) Is Null));

    SELECT tblPlantRelations.Plant_forsyn, tblPlants.RequestName, tblPlants.Plant
    FROM tblPlantRelations INNER JOIN tblPlants ON tblPlantRelations.Plant_offshore = tblPlants.Plant
    WHERE (((tblPlants.RequestName) Like 'A111111') AND ((tblPlantRelations.ImportType) Like 'Other'));
    Last edited by Ameneon; 01-18-11 at 14:45.

  2. #2
    Join Date
    Jan 2011
    Nevermind. Solved.
    New to sql so didn't really know much about aliases.
    I just added an alias for the subquery and then it was easy to add them together.

Posting Permissions

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