2011-06-03, 13:30 #1
- Join Date
- Apr 2004
- Jacksonville, Florida, USA
- Thanked 0 Times in 0 Posts
Opening vba query in another Access db
I do way more VBA in Excel than Access, but this time I need to open a query in another db from my db. I'm basically using the same code to run the other db that the other db uses, with a modified Set db=OpenDatabase("path"). However, I'm having trouble with the password on the other db. The code in the other db to run the password is
DoCmd.Close acQuery, "Logon_q"
This gives a "can't find the object 'Login_q' error in my db. How do I open and close this query from my db?
Subscribe to our Windows Secrets Newsletter - It's Free!
Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!
+ Get this BONUS — free!
Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!
2011-09-06, 11:50 #2
- Join Date
- Sep 2011
- Oklahoma City, OK
- Thanked 24 Times in 24 Posts
Docmd uses the currently opened database.
When use open another database that is assigned to the variable db then you must use commands that reference the db variable.
Is the query a select or action query?
If an action query then you can use:
db.Execute "Logon_q", dbFailOnError
Microsoft MVP - Access Expert
Last edited by HiTechCoach; 2011-09-07 at 12:45.