Accessing different database from one form

nyrob609

Registered User.
Local time
Today, 07:51
Joined
May 22, 2009
Messages
46
Hi,

I have different databases from different departments or my own and I find time consuming looking thru the folders or different sharedrives to access them. I could create short cuts on my desktop but I would like to create a form that list all the database and when I hit the command button I will open it. Is this possible? do I accomplish this by doing hyperlink or do I have to create a macro or vba code.

I wanted to create form just like my reports form where i did event procedure on click on open the report I choose but the only problem on DoCmd.Open I don't see an option to open database.
Else
If (Me.SelectReport) = "2151ApplicationTotal" Then
DoCmd.OpenQuery "2151TotalsReport", acViewPivotTable

Else
If (Me.SelectReport) = "2151ApplicationSpreadsheet (Maria)" Then
DoCmd.OpenQuery "2151ApplicationSpreadsheet (Maria)", acViewNormal


Using MS 2003

Thank you in advance for you input
 
Create a table which lists your database's file path and name. You can even have a field for a "friendly name" as well.

So, if you have

tblDbs
DatabaseFriendlyName
DatabasePathName

and then create a form bound to that table (using a query and sorted probably) in continuous form view and put a button on the form.

Put this code into a STANDARD MODULE (not form, report, or class module) and name it something other than the function name:

Code:
Function OpenOtherDb(strDbPathAndName As String)
Dim appAcc As Access.Application
 
Set appAcc = CreateObject("Access.Application")
appAcc.Visible = True
 
appAcc.OpenCurrentDatabase strDbPathAndName
 
appAcc.UserControl = True
 
Set appAcc = Nothing
 
End Function

and then you would call it from your form's button like:

Code:
Private Sub ButtonNameHere_Click()
   OpenOtherDb Me.DatabasePathName
End Sub

and using the continous form like that you can add or delete or modify the entries easily enough but just click on the button beside the one you want and it should open.
 

Users who are viewing this thread

Back
Top Bottom