Microsoft Access - Create an Inner Join Maketable DoCmd.RunSQL

Asked By Charles Bostic on 06-Jul-12 04:10 PM
I'm trying to join two tables into a single table similiar to a maketable by converting the query coding using VBA docmd.runsql.  The SQL for the query looks like this:

SELECT dbo_US_TS_Contact.Business_Partner_Number_for_Person, dbo_US_TS_Contact.Business_Partner_Number_for_Org, dbo_US_TS_Contact.p_name_first, dbo_US_TS_Contact.p_name_last, dbo_US_TS_Contact.p_fnctn, dbo_US_TS_Contact.p_department, dbo_US_TS_Company.c_name, dbo_US_TS_Company.C_Phone INTO US_Program
FROM dbo_US_TS_Contact INNER JOIN dbo_US_TS_Company ON dbo_US_TS_Contact.Business_Partner_Number_for_Org = dbo_US_TS_Company.Business_Partner_Number_for_Org;

I created a Insert INTO table placing values of the US_TS_Contact table into the newly created "US_Program" table and updating the "US_TS_Company" into the US_Program table by linking the ORG ids but it fails. Because the tables are very large (3.5 mil and 300K), I think its the size that's preventing it from executing but it works if I use the query wizard. 

When you get a chance. 
Pat Hartman replied to Charles Bostic on 25-Jul-12 04:12 PM
If it works from the query window, it will work from VBA.  Take the SQL from the querydef created by the QBE and paste it into VBA.  I have a strong preference for saving querydefs rather than using SQL strings in VBA.  They are easier to build and test and they can be reused if you take a little care with naming them.  Click and drag beats typing any day.