Check whether a form is opened as subform (3 Viewers)

I am going to set all the subform Tag properties with a "Subform" comment, then check the property as I loop through them.
FYI, that still would not help. How would you read the tag of a closed form? Still the same problem
The naming convention would be better except you may need a suffix for a form opened as either main form or subform.
However if I am building a ribbon for a user I doubt they want to see my form name since it is not super intuitive.
frmUseDtls
instead of showing them something like "Form User Details (frmUseDtls)".
 
Lets say you have a couple thousand forms and subforms and do not want to populate this by hand. Write some simple code to update the table. This gets rid of all the problems.
That's exactly what I am doing. Populating the FormTable with form names, then the VBA routine looks at each form name in the table and adds it to the RibbonUI Forms combobox list. But I only want the forms that are NOT subforms OR are already loaded to be available to be opened with the combobox. Populating a custom RibbonUI combobox is NOT a simple matter. I also have one for Reports. The Callbacks are a nightmare. 😩
 
FYI, that still would not help. How would you read the tag of a closed form? Still the same problem
The naming convention would be better except you may need a suffix for a form opened as either main form or subform.
However if I am building a ribbon for a user I doubt they want to see my form name since it is not super intuitive.
frmUseDtls
instead of showing them something like "Form User Details (frmUseDtls)".
No, I am opening the form in Design mode, checking the Tag property to see if it is a Subform, then closing the form and if the form is NOT a subform, then add it to the FormTable. First, I check to see if the form is loaded, if it isn't then check to see if it is a subform or not, if it is, do nothing, if it is not, add it to the table.

I know, working with the RibbonUI is not easy. Just telling you what I am attempting is giving me a headache.
 
Sorry, I am lost. Still no idea why at runtime you need to load the table. Why can't the table not be fully populated as I suggested.
A table with all forms that can be opened? Then if you need to simply mark those in the table as being already opened or closed.
 
@LarryE
Since you have the collection of form names in CurrentProject.AllForms, you can loop over that list, use SaveAsText, find the Begin Subform line and check its SourceObject property, here's a snippet of what that command outputs, it's like a blueprint of the form.

1727126569669.png


Also, whenever you have doubts about data types, you can open the Inspect window from the VBE IDE, add an inspection scoped for all modules and procedures, name it Application and you will get an expandable item where you can find out the properties of what is loaded. The error you refer to in post #8 was thrown because you were trying to reference a Form property but the object in your Loop was an AccessObject object, not a Form object.
1727126868450.png
 
Last edited:
In the specific case, @LarryE, you can step through and tag subforms if you wish. That is because if you are the author of the DB you would know which forms were intended for subform usage.

In the general and somewhat pedantic case, though, there is no such thing as as a subform. There is only a form that is loaded to a subform control. In the truly general case, that load action can be done dynamically at run-time, so it isn't even a static condition.
 
Still no idea why at runtime you need to load the table
Because to populate the custom RibbonUI, we need to do that. The Callbacks work fine and populates the combobox. My only problem was identifying and excluding sub-forms
 
In the specific case, @LarryE, you can step through and tag subforms if you wish. That is because if you are the author of the DB you would know which forms were intended for subform usage.

In the general and somewhat pedantic case, though, there is no such thing as as a subform. There is only a form that is loaded to a subform control. In the truly general case, that load action can be done dynamically at run-time, so it isn't even a static condition.
Yes. That is why I originally thought the IsSubform custom function might work but it has the same problem. Just learning new stuff at 75 years old. They say it's never too late, but maybe it is....:rolleyes:. I'll just do it the easy way and rename the sub-forms as sub-forms and identify them that way. Opening and reading each forms Tag is a pain and it's cocktail o'clock anyway. I've been trying to learn how to populate and use a custom RibbonUI combobox for opening forms and reports.
 
@LarryE
Since you have the collection of form names in CurrentProject.AllForms, you can loop over that list, use SaveAsText, find the Begin Subform line and check its SourceObject property, here's a snippet of what that command outputs, it's like a blueprint of the form.

View attachment 116196

Also, whenever you have doubts about data types, you can open the Inspect window from the VBE IDE, add an inspection scoped for all modules and procedures, name it Application and you will get an expandable item where you can find out the properties of what is loaded. The error you refer to in post #8 was thrown because you were trying to reference a Form property but the object in your Loop was an AccessObject object, not a Form object.
View attachment 116197
Neat little utility there!
 

Users who are viewing this thread

Back
Top Bottom