[AccessD] Open an Access DB from within the main DB
stuart at lexacorp.com.pg
Tue Oct 11 14:52:59 CDT 2022
The code I showed does EXACTLY what you asked for.
You pass the name of the datanbase you want to analyse to the function
as "my DB"
Function ListTables(myDB As String) As Long
You then connect to "myDB"::
Dim db1 As dao.Database
Set db1 = DBEngine.OpenDatabase(myDB)
Youthen do whatever you want with "myDB", such as:
Set tdf = db1.TableDefs
if you want to analyse the tables in myDB.
On 11 Oct 2022 at 6:45, Arthur Fuller wrote:
> 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
> AccessD mailing list
> AccessD at databaseadvisors.com
> Website: http://www.databaseadvisors.com
More information about the AccessD