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

VBA Queries in another DB

P: 18

I have a blank DB where I have a button to open another DB and 'try' to run queries located in there, but when my code runs it tries to run the query name in the blank DB rather than the newly opened DB.

Is there anyway in code to activate the newly opened DB in order to run the queries.

The code I have is

Expand|Select|Wrap|Line Numbers
  2. Dim objAccess As Access.Application
  3. Dim strDB1 As String
  4. Const strConPathToSamples = "C:\My Documents\db1.mdb"
  6. Set objAccess = CreateObject("Access.Application")
  7. With objAccess
  8. .OpenCurrentDatabase (strConPathToSamples)
  9. End With
  12. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "1 CHECK FILE STATUS QUERY", "C:\My Documents\\Manual Checks\MC", True

Thanks in advance

Apr 16 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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