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
Thanks
Phil
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,
Nz(PWD))
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
ShowObject_Err:
MsgBox Err.Description
End Sub