By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Format problem with SELECT FROM IN

P: 24
I'm copying a table into a newly renamed database with the statement SELECT INTO IN FROM. As long as I provide the full path within the single quotation mark everything works fine. But I want to provide the new database name as a a string. I tried all the combinations (single quotation marks, double qutation marks) but nothing works, it always gives me an error. Anybody has solution for that? Any help will be more than appreciated. Here is the code I'm trying to execute.
Expand|Select|Wrap|Line Numbers
  1.  
  2. strDBName = "C:\MATLAB\DB\NEWPROJECTS\NEW_DBPROJECT"
  3.  
  4. '******This is the working statement
  5. 'DoCmd.RunSQL " SELECT * INTO [tblPortfolioRepartition] IN 'C:\MATLAB\DB\NEWPROJECTS\NEW_DBPROJECT' FROM [tblPortfolioRepartition] "
  6.  
  7. '******This is the non-working statement
  8. DoCmd.RunSQL " SELECT * INTO [tblPortfolioRepartition] IN ' ' & strDBName & ' ' FROM [tblPortfolioRepartition] "
Mar 15 '10 #1

✓ answered by mabrynda

Sorry for bodering you.
I did something wrong. The statment works with:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "SELECT * INTO [tblPortfolioRepartition] " & _
  2.              "IN '" & strDBName & "' " & _
  3.              "FROM [tblPortfolioRepartition] "

Share this Question
Share on Google+
4 Replies


P: 24
Sorry for bodering you.
I did something wrong. The statment works with:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "SELECT * INTO [tblPortfolioRepartition] " & _
  2.              "IN '" & strDBName & "' " & _
  3.              "FROM [tblPortfolioRepartition] "
Mar 15 '10 #2

ADezii
Expert 5K+
P: 8,597
Try:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "SELECT * INTO [tblPortfolioRepartition] IN '" & strDBName & "' FROM [tblPortfolioRepartition]"
Mar 17 '10 #3

P: 24
Thanks,
It works fine.
Mar 17 '10 #4

ADezii
Expert 5K+
P: 8,597
You are quite welcome.
Mar 17 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.