I've experimented on several options to copy a table from an external database into my local Access table. After so many attempts and internet searches, my efforts were unsuccessful. So far the script below looks promising as it's only giving me "Invalid Argument" error. Please help as I'm quite desperate already. Thanks a lot.
strsql = "SELECT * INTO MyLocalTable FROM [Provider=SQLOLEDB.1;User ID=MyID;password=MyPass;Initial Catalog=MyDatabase;Data Source = MyDataSource;].MyDbTables;"
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandText = strsql
.CommandType = adCmdText
.Execute 'ERROR!!!! Invalid Argument
End With
strsql = "SELECT * INTO MyLocalTable FROM [Provider=SQLOLEDB.1;User ID=MyID;password=MyPass;Initial Catalog=MyDatabase;Data Source = MyDataSource;].MyDbTables;"
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandText = strsql
.CommandType = adCmdText
.Execute 'ERROR!!!! Invalid Argument
End With