[AccessD] Call a function in an AccDb from outside it?
Arthur Fuller
fuller.artful at gmail.com
Thu Oct 13 20:02:56 CDT 2022
To all you people who I am distracting from profitable coding: thank you
sooo much for taking the time required to think about my petty problems,
and even write sample code to help me get from A to B. I am so grateful to
you all.
In previous years, I think I provided more help and answers than I did ask
questions, but time goes on, the available grey cells diminish, and the
balance tilts. Now I find that I am asking more than answering. And I am
grateful to you all for helping me solve problems on an entirely new level.
In the past, most of the questions I asked and answered concerned specific
problems, as opposed to more abstract problems concerning the Access
internals. The previous stuff was easy; the new stuff is pretty much new to
me, and I appreciate your insights.
I should add that nobody is employing me to build this utility that is
barely 1/2 the way off the ground. When it is finally done, I intend to
give it away, and on its Help/About page there will be mentions of everyone
who has provided guidance, sample code, etc. Said About page may require a
Scrollbar. 😀
Alternatively, when this thing is finally done, I think it may be useful.
To that end, I'm thinking of charging a small fee for its license, and
distributing its income-generation among those listed in the Code
Contributors list. Or I could just sidestep all that crap and just give it
away. In about one month, I shall turn 75 years old, and the last thing I
need is another administrative/economic task!
I'd say I'd rather bask in the sun and watch scantily-clad women walk by,
but in Toronto in winter, those are few and far between. So I'll skip the
drama and just give it away, and the Help/About page will require a
scrollbar. So be it. I think of it as the debt that I owe this most
valuable community.
On Thu, Oct 13, 2022 at 7:27 PM Stuart McLachlan <stuart at lexacorp.com.pg>
wrote:
> 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
> >
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
--
Arthur
More information about the AccessD
mailing list