title: Troubles with joining tables in Excel VBA
body: <p>I'm trying to take a crystal report sql and convert it so I can use it in excel.  I'm having troubles with the syntax of the joining statements in Excel.  I can do a couple of tables individually, but cant combine them.</p>
  
  <p><em>From crystal reports:  What I'm trying to copy:</em></p>
  
  <pre><code>SELECT "Material_Req"."Job", "Material_Req"."Pick_Buy_Indicator", "Material_Req"."Material", "Material_Req"."Description", "Material_Req"."Vendor_Reference", "PO_Detail"."PO", "Material_Req"."Est_Qty", "Source"."Act_Qty", "PO_Header"."Vendor", "PO_Detail"."Due_Date"
   FROM   (("PRODUCTION"."dbo"."Material_Req" "Material_Req" LEFT OUTER JOIN "PRODUCTION"."dbo"."Source" "Source" ON "Material_Req"."Material_Req"="Source"."Material_Req") LEFT OUTER JOIN "PRODUCTION"."dbo"."PO_Detail" "PO_Detail" ON "Source"."PO_Detail"="PO_Detail"."PO_Detail") LEFT OUTER JOIN "PRODUCTION"."dbo"."PO_Header" "PO_Header" ON "PO_Detail"."PO"="PO_Header"."PO"
   WHERE  "Material_Req"."Pick_Buy_Indicator"='b' AND "Material_Req"."Est_Qty"&gt;"Source"."Act_Qty"
   ORDER BY "Material_Req"."Job"
  </code></pre>
  
  <p><em>Previous one that worked:</em></p>
  
  <pre><code>sqlMatlReq = "select job.job,  material_req.vendor_reference, material_req.Material,'' As Description, material_req.Vendor," _
          &amp; "(material_req.est_qty) As Qty, (material_req.act_qty) As Qty,   " _
          &amp; "material_req.due_date, " _
          &amp; " material_req.status " _
          &amp; "from (material_req inner join job on material_req.job=job.job) " _
          &amp; "left join material on material_req.material=material.material " _
          &amp; "where material.material is not null " _
          &amp; "and job.part_number is not null " _
          &amp; "and Job.Status in('Active') " _
          &amp; "and material_req.act_qty in('0') " _
          &amp; "Union all " _
          &amp; "select job.job, material_req.vendor_reference, material_req.Material, material_req.description, material_req.Vendor," _
          &amp; "(material_req.est_qty), (material_req.act_qty) As Qty," _
          &amp; " material_req.due_date, material_req.status " _
          &amp; "from (material_req inner join job on material_req.job=job.job) " _
          &amp; "left join material on material_req.material=material.material " _
          &amp; "where material.material is null " _
          &amp; "and job.part_number is not null " _
          &amp; "and Job.Status in('Active') " _
          &amp; "and material_req.act_qty in('0') " _
          &amp; "order by job.job;"
  </code></pre>
  
  <p><em>As far as I got:  having troubles combining the three</em> </p>
  
  <pre><code>'sqlMatlReq = "select job.job, material_req.material, material_req.Vendor_Reference, material_req.description, material_req.Est_Qty  " _
        '&amp; "from (material_req inner join job on material_req.job=job.job) " _
  
  'sqlMatlReq = "select source.Act_Qty, PO_Detail.PO, PO_Detail.Due_Date " _
        '&amp; "from source left outer join PO_Detail on source.Act_qty=PO_Detail.PO_Detail "
  
  'sqlMatlReq = "select PO_Header.vendor " _
        '&amp; "from PO_Header"
  </code></pre>
  
  <p>Thanks in advance.</p>