Open db from another Access db

Plukey

Board Regular
Joined
Apr 19, 2019
Messages
138
Office Version
  1. 2016
Platform
  1. Windows
Trying to open a different access db from my Data base using button / VBA. The code opens the db but i get an error after. If anyone knows an easier way, I'm open to ideas.

VBA Code:
Dim accapp As Access.Application
 
Set accapp = New Access.Application
 
accapp.OpenCurrentDatabase ("C:\PATH")
This is the error Im getting afyter the Data base opens
1670942883402.png
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Why are you trying to do this?
What is the automate goal here?

If you just want access to the data in the other database, a better option may be to just link the tables from the one database to the other.
 
Upvote 0
Why are you trying to do this?
What is the automate goal here?

If you just want access to the data in the other database, a better option may be to just link the tables from the one database to the other.
I have a set of shortcuts on the main page for users to use. Its just another database to use as a tool for our work. The company recently updated/upgraded the database with a new path on ouR shared drive. I replaced the path & it opens but I get that message now.
 
Upvote 0
More info please. List the steps you envision for using this approach.

I used the following in opening other databases and listing all tables.
Hope it's helpful..


VBA Code:
'---------------------------------------------------------------------------------------
' Procedure : Multi_MDBs
' Author    : user
' Date      : 3/30/2008
' Purpose   : Used to identify linked tables in a list of databases.
'---------------------------------------------------------------------------------------
'
Sub Multi_MDBs()
      Dim ThisDB As DAO.Database
      Dim otherDB As DAO.Database
      Dim strDbPath As String
      Dim rs As Recordset
      Dim rz As Recordset

      Dim tdf As TableDefs
      Dim i As Integer
      Dim MyBEPath As String
      Dim strMsg As String
      Dim sResponse As Variant
10       On Error GoTo Multi_MDBs_Error

20    On Error Resume Next
      Dim tbl As TableDef
30       On Error Resume Next
       
40    Set ThisDB = CurrentDb

50    Set rs = ThisDB.OpenRecordset("Select fullMDBCoord from A2Kmdbs")
60    Open "c:\jack\LinkedTbls.log" For Append As #1
70    Do While Not rs.EOF
80    blnTitlePrinted = False

90        Debug.Print Now & " - Processing  " & rs!fullmdbcoord
         ' If rs!fullmdbcoord <> "D:\A2K\db1_Backup.mdb" Then
         ' GoTo MoveIt
         ' End If
100       strDbPath = rs!fullmdbcoord
110      Set otherDB = OpenDatabase(strDbPath)
120      Set tdf = otherDB.TableDefs
130      Debug.Print "Checking tables in "; otherDB.name & vbTab & Now()
140   For i = 0 To tdf.Count - 1
150   MyBEPath = Mid(tdf(i).Connect, 10)
160   Debug.Print tdf(i).name
.....,.
 
Upvote 0
What I don't get here is the idea of trying to open a vbs file as an Access db. Or is it just that there's too much code missing to see what's really going on? :unsure:
I don't think that saying what the 2nd db is or is used for really answers the question of why.
 
Upvote 0
What I don't get here is the idea of trying to open a vbs file as an Access db. Or is it just that there's too much code missing to see what's really going on? :unsure:
I don't think that saying what the 2nd db is or is used for really answers the question of why.
Apologies for any confusion... Novice here!

Our group has a database we use for our job function. On our main page there are a list of shortcuts. Im using an Event procedure on the label to open another Db in our shared network. Our department recently updated the Db due to a few issues. They changed the path, i replaced the path and it does open the Db but gives the error above after it opens.

VBA Code:
Private Sub Label442_Click()
Dim accapp As Access.Application
 
Set accapp = New Access.Application
 
accapp.OpenCurrentDatabase ("C:***********************.accde")

End Sub
 
Upvote 0
More confusion. You edited posted code to show you're trying to open accde file yet the message says it can't open a vbs file.
In my Access version, labels don't have events. I doubt they ever did either.
 
Upvote 0
More confusion. You edited posted code to show you're trying to open accde file yet the message says it can't open a vbs file.
In my Access version, labels don't have events. I doubt they ever did either.
1670947429493.png

1670947508859.png
 
Upvote 0
You're right. Attached labels don't have events. Unattached to. My gray matter is not what it used to be - apologies.
Still, that doesn't seem to reveal why the file in code is accde but the message refers to a vbs file.
Maybe the opened database is where the error is being raised from, and it has something to do with the broad changes that you mentioned.
 
Upvote 0
You're right. Attached labels don't have events. Unattached to. My gray matter is not what it used to be - apologies.
Still, that doesn't seem to reveal why the file in code is accde but the message refers to a vbs file.
Maybe the opened database is where the error is being raised from, and it has something to do with the broad changes that you mentioned.
Yea, i agree totally...Im gonna put this one on the back burner & get with the department that developed the new Db
thanks everyone! Sorry if i wasted anyone's time today!
 
Upvote 0

Forum statistics

Threads
1,215,139
Messages
6,123,259
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top