Answered by:
Navigation Form - switching subforms

Question
-
Hello,
How can I programatcially switch subforms on a navigation form?
Thanks.
Wednesday, February 29, 2012 3:44 AM
Answers
-
Me.subform_Ctl.SourceObject = "FormName"
Matthew Slyman M.A. (Camb.)
- Marked as answer by zdrae Wednesday, February 29, 2012 1:26 PM
Wednesday, February 29, 2012 9:20 AM
All replies
-
Me.subform_Ctl.SourceObject = "FormName"
Matthew Slyman M.A. (Camb.)
- Marked as answer by zdrae Wednesday, February 29, 2012 1:26 PM
Wednesday, February 29, 2012 9:20 AM -
Sorry, this is a reply to an old post but I haven't been able get the answer to work. Specifically, I haven't been able to get "Me.subform_Ctl.SourceOject = "FormName" to work. Perhaps I am misunderstanding where the code was used. In a code button on the Main Navigation form, it's load event, it's open event, or from code on a current loaded subform of the Navigation form I get a compile error "Method or Datamember not found".
I use the DoCmd.BrowseTo command and it works to switch to frmDesiredSubform:
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmDesiredSubform", _
PathToSubformControl:="Navigation Form.NavigationSubform", _
DataMode:=acFormEdit("[Navigation Form]" enclosed in square brackets did not work, which seems to contradict the notion that they should enclose structure names containing spaces!!.)
I still would like to know how or where Matthew Slyman gets his code to work.
- Edited by bones216 Sunday, December 30, 2012 9:59 PM Discovered an answer
Sunday, December 30, 2012 7:21 PM -
To TEMPORARILY change the Source Object of a subform you can use:
Me.SubFormName.SourceObject="FormName"
Me.Requery
I would create a button on the mainform to do this since it is temporary.
But be careful, if the subform is linked to the main form through master and child fields, the new subform needs to have the same master and child fields.
You didn't say why you want to do this or under what circumstances but if I wanted to display different objects on a form, I would create a Tab Control and embed any subforms in the tabs. That is a much better and cleaner way to display different objects such as reports and forms. Just click a tab and view the data.
- Proposed as answer by Lawrence Ellefson Sunday, December 30, 2012 10:28 PM
Sunday, December 30, 2012 10:28 PM