By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,974 Members | 1,612 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,974 IT Pros & Developers. It's quick & easy.

Open a query or table in another database in design view.

P: n/a
I am trying to view the design of tables and queries in another database.

This is the code on a form, "ObjectName.Column(0))" is the name of a table
or query selected from the other database. I also have the ObjectID which is
in the other database MSysObjects (in case it is needed).

Case 1 is for tables and case 5 is queries.

The Set OtherTableDef and Set OtherQueryDef work OK, but not the OpenTable
Error is "Microsoft Acces can't find the object ........"

Any ideas



Private Sub ObjectName_DblClick(Cancel As Integer)
Dim AccApp As Access.Application
Dim OtherDb As Database
Dim OtherTableDef As TableDef
Dim OtherQueryDef As QueryDef

On Error GoTo ShowObject_Err
' Save for later

Set AccApp = New Access.Application
Set OtherDb = AccApp.DBEngine.OpenDatabase(DatabaseName, False, False,

Select Case ObjectTypeID

Case 1 'Tables
Set OtherTableDef = OtherDb.TableDefs(ObjectName.Column(0))
' This works
DoCmd.OpenTable OtherTableDef.Name, acViewDesign
' This doesn't work

Case 5 'Queries
Set OtherQueryDef = OtherDb.QueryDefs(ObjectName.Column(0))
' This works
DoCmd.OpenQuery OtherQueryDef.Name, acViewDesign
' This doesn't work

Case Else
MsgBox "Unknown Error", vbCritical

End Select
Exit Sub

MsgBox Err.Description

End Sub
Dec 13 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.