Solved Passing forms from one subform to another... (1 Viewer)

LucasGills69

New member
Joined
Apr 25, 2024
Messages
5
I have a form which I use as the main container for my application.

It contains a menu on the left, a header that serves as the title bar, a footer that serves as the status bar and a sub-form that shows the current functionality. When the user selects a menu item on the left, I simply load the corresponding form into the subform. All very nice and working.

Now I would like to give the user the possibility to keep the current form open when he selects another functionality. In other words I'd like to allow him to have multiple "open windows", all the while keeping my main form containing the menu on screen.

So when the user selects another menu item, the open form should be "parked" somewhere before the new form is loaded into the subform.

To do this, I have several hidden subforms on the main form that I use to store all open forms. I simply switch the forms between the visible subform and the hidden ones, depending on what the user selects in the menu.

A bit cumbersome... but you get the idea ;)

The problem is... that it doesn't work as planed. This is because I'm using the subform SourceObject property when I switch the forms and this has the effect of loading another fresh instance of the specified form instead of the one which is already open.

Does anybody know if it's possible to "pass" forms already loaded from one container to another ? I searched for some kind of Set instruction instead of SourceObject -which requires a string- but couldn't find any.

Thanks for your help.

Lucas
 
I have a form which I use as the main container for my application.

It contains a menu on the left, a header that serves as the title bar, a footer that serves as the status bar and a sub-form that shows the current functionality. When the user selects a menu item on the left, I simply load the corresponding form into the subform. All very nice and working.

Now I would like to give the user the possibility to keep the current form open when he selects another functionality. In other words I'd like to allow him to have multiple "open windows", all the while keeping my main form containing the menu on screen.

So when the user selects another menu item, the open form should be "parked" somewhere before the new form is loaded into the subform.

To do this, I have several hidden subforms on the main form that I use to store all open forms. I simply switch the forms between the visible subform and the hidden ones, depending on what the user selects in the menu.

A bit cumbersome... but you get the idea ;)

The problem is... that it doesn't work as planed. This is because I'm using the subform SourceObject property when I switch the forms and this has the effect of loading another fresh instance of the specified form instead of the one which is already open.

Does anybody know if it's possible to "pass" forms already loaded from one container to another ? I searched for some kind of Set instruction instead of SourceObject -which requires a string- but couldn't find any.

Thanks for your help.

Lucas
If I understand what you want to do, I think you might be able to pull it off, but I'm hard pressed to see the benefit. What business purpose would it serve? I understand what you want to do, but why is not that clear?
 
There are two techniques I use.

One is simply to have two subform controls, one hidden or at least sized to zero width or height and when required it is resized and populated with the second form - whether you have them side by side or one above the other is up to you. Depends on how much monitor real estate you have and need. You may have to resize the first subform to accommodate the second one for example.

For more than two forms, I use a button to run some code to create an instance of the form in the subform control. The instance is a pop up so the user can move it to wherever they feel is convenient. They can then return to the 'main' control to modify as required.

Depends on the app, but my SOP is to offset the form from the top/left of the subform control when it is opened so user can see they now have two instances. This can be repeated as many times as you like within the constraints of memory - I've gone over 20 instances in testing. Typical use would be you want to manually compare two or more records.

Another method I have used is to simply have a popup menu form which opens other forms as popups and they can all be moved around the screen and resized as the user sees fit. But this does not have the header and footer you refer to although it can be accommodated in other popups than can't be moved.
 
Modifying the form's Me.SourceObject will definitely force a reload of the form. Any of the properties that start like Me.Sourcexxx (or control.xxxSource) will have an immediate effect. I.e. you do SOMETHING to a displayed form or control if you change the source parameter for that item. Access is dynamic like that.

CJ's idea that plays with visibility avoids reloading a source parameter so won't affect content.
 
If I understand what you want to do, I think you might be able to pull it off, but I'm hard pressed to see the benefit. What business purpose would it serve? I understand what you want to do, but why is not that clear?
Hi George

It's all about managing adequately the working space.

Since I want the application frame (menu, header and so on) to stay in place whatever the user does, the easiest way is to use a sub-form for the working area.

This allows me to keep control of the different elements. I don't want to have multiple windows all over the place that may hide the menu for instance.

To better explain I show you below what it looks like.

Initial view with no function started :
Main screen - Empty.png


View with two functions started, of which one is parked :
Main screen - Débiteurs.png


I hope this helps to better understand what I want to achieve.

Cheers
 
Thank you, that does help visualize the scenario. I have used a similar approach many times over the years. Sometimes with command buttons as the menu, once or twice using hyperlink text fields, and often with a list box.
This one is not full screen on my monitor because it's designed to run on a laptop. It looks fine on that laptop. It also doesn't yet have a custom ribbon.
1714133738643.png


My confusion refers more to the "parking" of subforms. There have been many good ideas about hiding and displaying subform controls.
I guess it might help to bring in the concept of state to explain my problem.

Right now, the state of the form in the screenshot is that it has no records in its recordset. If I select a book, though, the state of that form will now be different, i.e. it will one record in its recordset.
1714134068111.png


I don't see how I can remove this subform, with that selected record intact as its recordset, and "park" it anywhere. That's the only way I could see to replace it in the subform control.

Again, there's been a lot of excellent discussion about similar approaches with hiding and displaying forms or subcontrols on forms, etc. Even creating multiple copies of forms.

I would be impressed by some technique to do it, but it's not immediately apparent to my how that's going to be possible
 
Thank you, that does help visualize the scenario. I have used a similar approach many times over the years. Sometimes with command buttons as the menu, once or twice using hyperlink text fields, and often with a list box.
This one is not full screen on my monitor because it's designed to run on a laptop. It looks fine on that laptop. It also doesn't yet have a custom ribbon.
View attachment 113846

My confusion refers more to the "parking" of subforms. There have been many good ideas about hiding and displaying subform controls.
I guess it might help to bring in the concept of state to explain my problem.

Right now, the state of the form in the screenshot is that it has no records in its recordset. If I select a book, though, the state of that form will now be different, i.e. it will one record in its recordset.
View attachment 113847

I don't see how I can remove this subform, with that selected record intact as its recordset, and "park" it anywhere. That's the only way I could see to replace it in the subform control.

Again, there's been a lot of excellent discussion about similar approaches with hiding and displaying forms or subcontrols on forms, etc. Even creating multiple copies of forms.

I would be impressed by some technique to do it, but it's not immediately apparent to my how that's going to be possible
"I don't see how I can remove this subform, with that selected record intact as its recordset"
That's exactly the point, I want to keep the content of the sub-form in its current state in case the user wants to revert to it after starting another function.

As CJ wrote, the way to go is certainly to have several sub-forms and play with their Visible property.

That's what I had started to do but my mistake was the design of it : I wanted to have a single visible sub-form (the active one) and switch its content with the one stored in several hidden mini sub-forms (the inactive ones placed in the footer).

Instead of that I will place all the sub-forms in full size at the same location in the detail section and simply show/hide them accordingly.

Thanks again for your help.
 

Users who are viewing this thread

Back
Top Bottom