Open Access from within Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to open multiple Access databases from within a single Access
database programaticly. The databases I would like to open each have unique
Workgroup files and logins. Is it possible to set the appropriate workgroups
for each of these databases and open them from within VBA? I am using Access
2003.
 
You can set a reference to other Access files and run code from those files.
So, say I set a reference to another database and have standard module with
a subroutine in the database like:

Public Sub OpenContractors()
DoCmd.OpenReport "rptContractors", acViewPreview
End Sub

Then in the first database, I can have a command button in a form:

Private Sub cmdOpen_Click()
OpenContractors
End Sub

and the report will open in my current database. To set a reference, go to
any code window and choose Tools > References and change the file type to
mdb or mde then browse for the path to the second database. Once the
reference is set, you can call forms, reports and code, like I show above.
 
Thanks for your help Arvin that is pretty slick. However, I tried to set a
reference to a secured database and I got an error (note: it worked for the
un-secured database). The database I am trying to open has a different
Workgroup file than the database I am in when I call the procedure. I assume
I would need to somehow point to this Workgroup file in order for this to
work? Is there another way to just open a database and tell it what Workgroup
to use from with VBA.

Your help is greatly appreciated.
 
There is a way to open a file that's in a different workgroup, but I don't
know how it could work with this code. I know it works if you have joined
the same workgroup. Perhaps, you could join the secure workgroup, and use
the code to open the non-secure one? The shortcut would look like:

"C:\Program Files\Path to msaccess.exe" "C:\Path to database" /wrkgrp
"C:\Path to workgroup"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top