What method is best to open another database from an Access switchboard?

I have an Access database (BE / FE) that I have utilized switchboards.  I want to open another database in a new window.  I presume I can either use the "Run Macro" or
Run Code" command.  I am most comfortable creating a macro and calling it from the switchboard.

Can someone help me with the method to create a macro that opens a separate database in a new window?
David G. SmithOwnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You can use the RunCode command to a Function like this ( example)

Public Function mOpenDbInWindow

Dim obj As Application
Set obj = CreateObject("Access.Application")
obj.Visible = True
obj.OpenCurrentDatabase ("FullPathAndDbNameHere")
obj.UserControl = True
Set obj = Nothing


'  other code

Set obj = Nothing  '

End  Function

mx
0
danishaniCommented:
Or simplified version:

Public Function OpenDb()

Dim strPath As String

strPath = "C:\YourPath\Yourfile.accdb"

Application.FollowHyperlink strPath, , True

End Function

Then in Macro, using RunCode, enter the Function name OpenDb().

Hope this helps,
Daniel
0
danishaniCommented:
Well the Query contains a selection from a Table or more Tables.

So the Delete statement will be almost the same, but instead of SELECT command you need to use the DELETE command.
Basicaly creating a DELETE query.

See below thread:
http://www.fmsinc.com/microsoftaccess/query/snytax/delete-query.html#DELETE%20Query%20SQL%20Syntax

Hope this helps,
Daniel
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

danishaniCommented:
Please ignore the last post, it was meant for different thread.
For some reason ended up in this thread (?)

If possible delete.
0
David G. SmithOwnerAuthor Commented:
Ok, I tried to complete the solution submitted by Daniel "danishani" but i get an "Action Failed "Error Number 2950".

I am working in an Access 2007 database and trying to open a .mdb file.  Is this a problem?

My code is below.
Public Function OpenDb()

Dim strPath As String

strPath = "\\brc-cor-fp01\mas90\1 Quality\Training\Training Records.mdb"

Application.FollowHyperlink strPath, , True

End Function

Open in new window

0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"I am working in an Access 2007 "
Is the db you are trying to open in a Trusted Location ?

mx
0
danishaniCommented:
I have tested it, and it worked for me.

Make sure you have compiled the Function OpenDb() and saved it in a seperate Module in your database.

Hope this helps,
Daniel
0
danishaniCommented:
Another thing, make sure you have enabled Macro's, and run in Trusted Location.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
In fact see this link on that exact error:

http://support.microsoft.com/kb/931407

mx
0
David G. SmithOwnerAuthor Commented:
Yes:
\\brc-cor-fp01\mas90\

is trusted  (with subfolders)
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Well, error 2950 is a relatively new error number (A2007) and specifically deals with Trusted Locations.  Did you look at the KB above ?

mx
0
David G. SmithOwnerAuthor Commented:
Yes I looked at the KB.  I have ensured that both locations of each database is in a trusted location.  Both databases have Macros enabled.  Still does not work for some reason.

The host DB is on a terminal server (Remote Desktop) and is calling to open a database elsewhere on the server.  I read where this may be more difficult.  Could this be the issue?
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"Could this be the issue?"
My guess: Yes ... if you already have TL's set up.

I don't know the solution ...

mx
0
David G. SmithOwnerAuthor Commented:
Update:
The code works like a charm when ran from Visual Basic.  But it gives me the error when run from the switchboard.  

I decided to make a blank form and add a button that runs a macro (runcode).  No luck!  But this time it says the database can't find the function.  Then it gives me the error.
0
danishaniCommented:
Make sure the Module is saved with a different name then the Function.
Did you saved it in a seperate Module?


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David G. SmithOwnerAuthor Commented:
Daniel, that was it!!!!  Thank you so much.  It works.  Above you mentioned to make sure it was saved in a separate module - I did that but I gave it the same name.  Now that I named the Module different from the Function, it works perfectly.  
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
danishani:
Good one - hyperlink !

mx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.