Storing queries

G

Guest

I have multiple clients that have an MDB. The MDB has the same tables but
some of the queries, reports and macros are different. I'd like to create
one master database with all the objects. Do you have any suggestions on the
best way to organize this mess?
 
P

Pieter Wijnen

well, it's your life <g>

Sub GetQueries()
Dim TDb As DAO.Database, FDb As DAO.Database
Dim TQd As DAO.QueryDef, FQd As DAO.QueryDef

Set TDb = Access.CurrentDb
Set FDb = Access.DBEngine.Workspaces(0).OpenDatabase("C:\Data\Db.mdb")
For Each FQd In FDb.QueryDefs
On Error Resume Next
Set TQd = TDb.QueryDefs(FQd.Name)
On Error GoTo 0
If TQd Is Nothing Then
Access.DoCmd.TransferDatabase acImport, "Microsoft Access", FDb.Name,
acQuery, FQd.Name, FQd.Name
Else
Set TQd = Nothing
End If
Next
FDb.Close: Set FDb = Nothing
Set TDb = Nothing

End Sub

Pieter
 
P

Pieter Wijnen

You paste it into a General module, Put the cursor somewhere in the code &
hit F5

HTH

Pieter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top