Click here to Skip to main content
15,885,137 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
:-D Morning,

I have a code segment that opens a remote Access db from another Access databse using VBA.
VB
Set oApp = New Access.Application
oApp.OpenCurrentDatabase !DirName
oApp.Visible = False
Set db = oApp.CurrentDb

'< the code here loops through the tabledefs and outputs the connection strings>

oApp.CloseCurrentDatabase
Set oDoc = Nothing
Set oMod = Nothing
Set db = Nothing
oApp.Quit acQuitSaveNone
Set oApp = Nothing

The part that I can not figure out is how to open the remote in Design mode? Some of the remotes have routines that run at open and this is not necessary for my purposes.

Thanks for any help!!!
Gene
email is: [Email removed]
Posted
Updated 15-Feb-11 3:34am
v2
Comments
Sandeep Mewara 15-Feb-11 9:35am    
1. Format code part using PRE tags - it makes the question readable
2. Never give your email id like you gave unless you like SPAM

1 solution

If you want to loop through the tabledefs, forms, queries and other objects you don't need to open access application, a specially if want to iterate objects in the current database. You can create query like this:
1) forms
SQL
SELECT Name
FROM MSysObjects
WHERE (Type = -32768)


2)tables and queries
SQL
SELECT Name
FROM MSysObjects
WHERE ((Type = 5) OR (Type = 6))



If you refer to DAO.xx, where xx is version of DAO (like 3.6) you can enum objects using collections of tables, queries and forms. Example for enum tables:
Sub EnumObjects()
Dim db As DAO.Database, tbl as DAO.TablDef

On Error Goto Err_EnumObjects

Set db = Currentdb
For each tbl In db.TableDefs
    Debug.Print tbl.Name
Next tbl


Exit_EnumObjects:
    On Error Resume Next
    Set db = Nothing
    Exit Sub

Err_EnumObjects:
    MsgBox Err.Description, vbExclamation, Err.Number
    Resume Exit_EnumObjects
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900