Hi!
Short question:
How to move the reference for a sub form from one main form to another?
Long question:
I have a main form with a sub form. The sub form contains links to other sub forms. When the user clicks on a link the sub form is unloaded and the new sub form is loaded in its place. This works perfect.
But the problem is that this is very similar to a website, so now the users want to have a history function also. They want to have the sub forms remember their state between going to different sub forms.
Example:
Sub form Orders contains a list of orders for a customer.
Sub form OrderDetails contains the details for an order.
The user can go to OrderDetails from Orders (then Orders get unloaded and OrderDetails get loaded in its place). When the user has finished looking at the details he/she moves back to the Orders (OrderDetails get unloaded and Orders get loaded).
Then the sub form Orders shall show the same state as before it was unloaded.
I want to do this by not unloading the sub form, but to change its reference to another main form (a hidden one) and then when I want to use it again, just change the reference back to the original main form.
I have tried this with this code:
But that somehow makes a copy of the original sub form. I have checked this by displaying a message when the OnLoad-event fires, and it does that after this line: frmSaved! SavedForm.SourceObject = Me.Parent.SubForm_f.SourceObject
Does anyone have a suggestion for how I shall solve this?
Ps. By changing sub form I can simulate a website and the users don’t have to bother with a lots of forms that opens up all the time, the interface is more slim this way.
Short question:
How to move the reference for a sub form from one main form to another?
Long question:
I have a main form with a sub form. The sub form contains links to other sub forms. When the user clicks on a link the sub form is unloaded and the new sub form is loaded in its place. This works perfect.
But the problem is that this is very similar to a website, so now the users want to have a history function also. They want to have the sub forms remember their state between going to different sub forms.
Example:
Sub form Orders contains a list of orders for a customer.
Sub form OrderDetails contains the details for an order.
The user can go to OrderDetails from Orders (then Orders get unloaded and OrderDetails get loaded in its place). When the user has finished looking at the details he/she moves back to the Orders (OrderDetails get unloaded and Orders get loaded).
Then the sub form Orders shall show the same state as before it was unloaded.
I want to do this by not unloading the sub form, but to change its reference to another main form (a hidden one) and then when I want to use it again, just change the reference back to the original main form.
I have tried this with this code:
Code:
Dim frm As Form, frmSaved As Form
Set frm = Me.Parent
If (Not IsLoaded("SavedForm_f")) Then
DoCmd.OpenForm " SavedForm _f"
End If
Set frmSaved = Forms("SavedForm _f")
frmSaved! SavedForm.SourceObject = Me.Parent.SubForm_f.SourceObject
Me.Parent. SubForm _f.SourceObject = "OrderDetails_f"
But that somehow makes a copy of the original sub form. I have checked this by displaying a message when the OnLoad-event fires, and it does that after this line: frmSaved! SavedForm.SourceObject = Me.Parent.SubForm_f.SourceObject
Does anyone have a suggestion for how I shall solve this?
Ps. By changing sub form I can simulate a website and the users don’t have to bother with a lots of forms that opens up all the time, the interface is more slim this way.