[AccessD] Call a function in an AccDb from outside it?

Stuart McLachlan stuart at lexacorp.com.pg
Thu Oct 13 18:27:17 CDT 2022


That will get you the names and properties of each form/report/module, but the Docmd stuff  
won't work with objects in another database and AFAIK, you can't get at the actual content 
of the objects.

It looks as though about all you can do with them is:

Function GetObjects(db As String,objType as string) As Long
    Dim db1 As DAO.Database
    Dim doc As DAO.Document
    Dim prop As Property
    Set db1 = DBEngine.OpenDatabase(CurrentProject.Path & "\" & db)
    For Each doc In db1.Containers(objtype).Documents
        Debug.Print doc.Name & " LastUpdate:" & doc.LastUpdated
        For Each prop In doc.Properties
            Debug.Print "  " & prop.Name & ": " & prop.Value
        Next
    Next
End Function
and call that with something like: GetObjects "test2.accdb", "forms"




On 13 Oct 2022 at 22:46, McGillivray, Don wrote:

> Hi Arthur,
> 
> I just ran this within a database and got a list of all of the forms
> and reports in the container.  You should be able to aim this at your
> remote DB as the target just as well.  If you want to see the
> attributes (data source, controls, etc.) of the form/report, you'll
> need to open it first and then do operations on the open instance. 
> That can be done in code, too, once you have the object names from the
> container.  I don't think there's any way to see into a form or report
> except by opening it, but the containers object lets you get to the
> names of the reports and forms so they can be opened and interrogated.
> 
> Function ShowMeTheFormsAndReports()
> Dim db As DAO.Database
> Dim doc As DAO.Document
> 
> Set db = CurrentDb()
> 
> For Each doc In db.Containers("forms").Documents
> 
>     Debug.Print doc.Name
> 
>     'To open the form:
>     DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
>     'do stuff with the open form
>     DoCmd.Close acForm, doc.Name, acSaveNo
> Next
> 
> For Each doc In db.Containers("reports").Documents
>     'do stuff with reports
> Next
> 
> Set db = Nothing
> End Function
> 
> - Don
> 
> -----Original Message-----
> From: AccessD
> <accessd-bounces+dmcgillivray=ctc.ca.gov at databaseadvisors.com> On
> Behalf Of Arthur Fuller Sent: Thursday, October 13, 2022 2:00 PM To:
> Access Developers discussion and problem solving
> <accessd at databaseadvisors.com> Subject: [AccessD] Call a function in
> an AccDb from outside it?
> 
> I'm still working on my problem of opening an AccDb within a running
> one. Thanks to Stuart, I now have that part working beautifully. But
> as they say, inside every beautiful solution lurks a monster ready to
> bite you.
> 
> So I've got my utility able to browse for a database to open, then
> list its TableDefs and QueryDefs. I want to move on to be able to
> process its forms, but I can't get at AllForms. Is there any way to do
> this?
> 
> Failing that, I thought that maybe I could write a function inside the
> "target" db (the one opened within my utility) and maybe call it from
> the utility DB? Is that possible?
> 
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdata
> baseadvisors.com%2Fmailman%2Flistinfo%2Faccessd&data=05%7C01%7Cdmc
> gillivray%40ctc.ca.gov%7Cc3af3faf74c74775c32208daad5dfe64%7C78276a93ca
> fd497081b54e5074e42910%7C0%7C0%7C638012916459722126%7CUnknown%7CTWFpbG
> Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%
> 3D%7C3000%7C%7C%7C&sdata=SKCLQdhGUog%2Fb2v8aT0cLpzfixw6Fh6A6aN1UjF
> OxVg%3D&reserved=0 Website:
> https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.d
> atabaseadvisors.com%2F&data=05%7C01%7Cdmcgillivray%40ctc.ca.gov%7C
> c3af3faf74c74775c32208daad5dfe64%7C78276a93cafd497081b54e5074e42910%7C
> 0%7C0%7C638012916459722126%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDA
> iLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sd
> ata=UUbLYPanNL6dBv3fc5yfpO6QrLr24Sat4Y%2B963Jy6c4%3D&reserved=0 --
> 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