returning form properties using vba

Is there a way, using VBA, to read through the list of forms in an Access database and return the setting for a specific property?  Specifically I would like to see what the MinMaxButtons property is set to on each form in the database
dsoderstromAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
yes, you can run the free Analyzer here:

https://github.com/strive4peace/Analyzer

and then make a query using the a_Forms1 table with:

  • f_Name
  • f_MinMaxButtons

If you have only analyzed one database, you will not need to filter the query for DbID (assigned each time an analysis is done).

have an awesome day,
crystal
0
PatHartmanCommented:
This will print out that specific property for all forms in the database.
Sub sDisplaySpecificProperty()
    Dim db As DAO.Database
    Dim ctr As Container
    Dim doc As Document
    Dim frm As Form
    Set db = DBEngine(0)(0)
    Set ctr = db.Containers!Forms
    For Each doc In ctr.Documents
        DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
        Set frm = Forms(0)
        Debug.Print frm.Name & " -- " & frm.MinMaxButtons
        frm.ShortcutMenu = False
        DoCmd.Close acForm, doc.Name, acSaveYes
    Next doc
End Sub

Open in new window

0
dsoderstromAuthor Commented:
Pat,
   I am trying to run your code and it's not working quite right.
   First, I took out the line "frm.ShortcutMenu = False" and I changed the Docmd.Close from acSaveYes to acSaveNo.  I don't want to modify anything.
   The problem I have is on the "Set frm = Forms(0).  After executing this line I'm thinking that the frm.name on the following line should match the doc.name on the preceding line but it does not.  frm.name is the name of a form but it does not match the doc.name.
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

PatHartmanCommented:
I didn't write the code.  I modified it to print out the specific property you wanted to see.

There is a bug and I'll see if I can figure it out.  It looks like when you run it the first time, you get a bogus list but if you run it a second time, the list is correct.  Try that for now and I'll look at the code.  I thought the bug was fixed once I got a good list.  I never closed the app and then reopened it and tried again.  It is a problem only the first time you run it.

The save property was set because the original code actually modified form properties so rather than removing the line of code, comment it out so it will jog your memory if you want to convert this to actually changing the property.
0
PatHartmanCommented:
I think I fixed it.  I changed this line --  Set frm = Forms(0) to  Set frm = Forms(doc.Name)
I also changed the Set db line to use Currentdb because I seem to remember some problem with the way the DBEngine(0)(0) reference refreshes.  I have no idea why the change I made fixed the problem.  I'm guessing that the Form(0) reference wasn't keeping up with the loop.  The real mystery is why it works the second time you run the loop.
Sub sDisplaySpecificProperty()
    Dim db As DAO.Database
    Dim ctr As Container
    Dim doc As Document
    Dim frm As Form
    Set db = CurrentDb
    Set ctr = db.Containers!Forms
    For Each doc In ctr.Documents
        DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
        Set frm = Forms(doc.Name)
        Debug.Print frm.Name & " -- " & frm.MinMaxButtons
        '''DoCmd.Close acForm, doc.Name, acSaveYes      '' use this line if you actually update the property
        DoCmd.Close acForm, doc.Name
    Next doc
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dsoderstromAuthor Commented:
Thanks Pat.  It works perfectly now.
And thanks Crystal for the link to the Analyzer.  I will be taking a closer look at it when I get a chance.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.