[AccessD] Open an Access DB from within the main DB

Paul Wolstenholme Paul.W at industrialcontrol.co.nz
Tue Oct 11 15:25:52 CDT 2022


Arthur,

Were you looking for my email (also on 24 August which Stuart then expanded
upon) that included:
=======
I did it once.
The crux of the code is a function that includes the parameter
    ByRef stDatabaseFile As String
and includes the statements
    ' Target database
    Dim dbTrg As DAO.Database

    Set dbTrg = DBEngine.Workspaces(0).OpenDatabase(stDatabaseFile)
    ... useful stuff
    Set dbTrg = Nothing
========

Paul.

On Tue, 11 Oct 2022 at 23:45, Arthur Fuller <fuller.artful at gmail.com> wrote:

> Stuart,
>
> No. I have all that code, for tables and queries and forms, etc.,and it
> works just fine -- if I copy the modules into the target database. That's
> what I want to avoid. I've got all that code in the utility database, as
> well as the code to let the user browse to select a database. And here's
> the rub. From within the utility database, I want to open the selected
> database, ideally in hidden mode, and then process it, and finally close it
> -- all this to happen from within the utility database.
>
> 1. user runs the utility database
> 2. user browses to select the database to process (target).
> 3. utility database opens the target.
> 4. the ListTables, etc. runs against the target, not the utility.
> 5. code closes the target.
> 6 Wash, rinse and repeat until the user closes the utility database.
>
> Does that make my intentions clearer?
>
> On Tue, Oct 11, 2022 at 3:43 AM Stuart McLachlan <stuart at lexacorp.com.pg>
> wrote:
>
> > On 10 Oct 2022 at 21:16, Arthur Fuller wrote:
> >
> > > I think I've asked this before, and received an answer, but can't find
> > > it.
> >
> > You mean this answer to essentially the same question less than 2 months
> > ago?
> >
> > On 24 Aug 2022 at 7:52, Stuart McLachlan wrote:
> >
> > > Yes.
> > > This gets the tables. Over to you to get the fields from them and
> > > populate comboboxes.
> > >
> > > Function ListTables(myDB As String) As Long
> > > Dim db1 As dao.Database
> > > Dim tdf As TableDefs
> > > Dim td As TableDef
> > > Set db1 = DBEngine.OpenDatabase(myDB)
> > > Set tdf = db1.TableDefs
> > > For Each td In tdf
> > >     Debug.Print td.Name
> > > Next
> > > End Function
> > >
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list