Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening another Microsoft Access DB from an Access DB

Status
Not open for further replies.

mns117

Programmer
Apr 8, 2002
32
US
I would like to be able to open 4 seperate Access DB's from 1 access DB. Basically I want a form with 4 buttons, depending on which one the user pushed a different access DB would open...any suggestions. Thanks!!! Mike
 
This may be of some use

I used it to open an IP Generator and issuues modules of a migration suite.

hence the paths and comments rem'd out at the bottom.

Edit where you need to.

To make all this function you have to


create a table - tbldirectoryPath - this will hold the paths to your databases.

Field name Type Size
----------------------------------------

directory text 50
subDirectory text 50
Name text 50
Objectname text 50
objectType text 50

example of record
directory
e:\ip applications\db_issues

subDirectory

Name
Issues Database

Objectname
issues.mdb

objectType
Database

copy these 2 routines into a module after creating and populating your table and then run them ..
any probs let me know and I'll check them out

appname is the name of your database to be opened including the .mdb

so if your database is say Salary.mdb
on your button you would put
Call launchLinkApps("salary.mdb")

and you are away

regards

Jo
Sub launchLinkApps(appname As String)
On Error GoTo COMLaunchLinkAppserr

Dim strdb As String
Dim strname As String
Dim applaccess As New Access.Application
Dim strFile As String
Dim rptpath As String
Dim response As Integer
Dim cnt As Integer

ChDir "C:\"
Dim rptname As String
Dim dirstr As String
rptname = appname

cnt = 0
rptpath = ListedPath(rptname) ' this reads the path from form data


ChDir rptpath
If CurDir <> rptpath Then
ChDir rptpath
End If
dirstr = rptpath & &quot;\&quot;

DoEvents
DoEvents
'The next 3 line opens the database
strdb = dirstr & appname
applaccess.Visible = True
applaccess.OpenCurrentDatabase strdb




'MsgBox &quot;This application is not included in this suite of programs. &quot; & vbCrLf & &quot; Please contact your administrator&quot;


'Const strdb = &quot;c:\unclas\IPGenerator\db_IPGenerator.mdb&quot;
'Const strdb = &quot;D:\Jo-2\edl\db_IPGeneratorV2.mdb&quot;
'Const strdb = &quot;D:\Jo-2\jo\Issues.mdb&quot;
DoCmd.Minimize
applaccess.Visible = True
'applaccess.DoCmd.OpenForm &quot;frmEmployeeNameDialog&quot;

comLaunchLinkAppserrexit:
Err = 0
Exit Sub
'Const strdb = &quot;D:\Jo-2\edl\db_IPGeneratorV2.mdb&quot;
'Const strdb = &quot;D:\Jo-2\jo\Issues.mdb&quot;
COMLaunchLinkAppserr:
MsgBox Error$(Err)
GoTo comLaunchLinkAppserrexit

End Sub





Function ListedPath(objname As Variant) As String

'j green
'This function retrieves the value of the directory path field from tbldirectoryPath
'and returns it to the function ..... so that the output can be created in the right place


On Error GoTo ListedPatherr
Dim mydb As Database
Set mydb = CurrentDb()
Dim myrs As Recordset


Set myrs = mydb.OpenRecordset(&quot;tblDirectoryPaths&quot;, dbOpenDynaset)
With myrs

.FindFirst &quot;[objectname] ='&quot; & objname & &quot;'&quot;


If .NoMatch Then
MsgBox objname & &quot;Cannot be located.&quot; & vbCrLf & &quot;Please contact your Line Manager and report the object has been removed&quot;
Else
ListedPath = !directory
End If
End With
ListedPatherrexit:
Err = 0

Exit Function
ListedPatherr:

MsgBox Error$(Err) & Err
GoTo ListedPatherrexit


End Function



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top