Hi,
I was wondering if there is a simplistic way of copying the structure of one table into a NEW table - but only specific fields.
docmd.transfer database doesn't seem to allow passing SQL string as an object, unless i have a mistake:
Code:
DoCmd.TransferDatabase acImport, "Microsoft Access", CurrentDb.Name, acTable, "SELECT ContactID, Company, Name, Phone, Email FROM Contacts;", "Temp_VendorContacts", True
The only other option is using a MAKE TABLE query such as...
Code:
sql = "SELECT ContactID, Company, Name, Phone, Email INTO Temp_VendorContacts FROM Contacts;"
However, this will copy the data as well, which is not desired. I can get around this by putting in a WHERE clause for an extremely unprobable value to have a return of 0 records:
Code:
sql = "SELECT ContactID, Company, Name, Phone, Email INTO Temp_VendorContacts FROM Contacts WHERE ContactID = '" & "$#$#$#" & "';"
The issue with this approach is that it is running a WHERE query, thus still using computational resources for something that really doesn't need it.
So, my question is, is there a simpler/better way? I could write a function to do this task but I would rather not.....
Thanks