PDA

View Full Version : Solved: Using the Pages Collection



jauner
11-22-2005, 11:42 AM
I have an interesting problem. I have a form that has a tabbed control that contains subforms. How do I reference those subforms whether the certain tab is active or not from the main form.

I am also having a related problem when I try to execute the following line:

Forms![frmCasualty Audit]!frmMLS.Form.LoadMLS (strAccountType)

I am getting a run time error 2455 and the frmMLS is the correct subform object name.

chocobochick
11-22-2005, 02:49 PM
Is it a 2455 or a 2465 error? I can reproduce the 2465 when I have a typo or incorrect name for an object in the procedure call, but I can't reproduce anything that generates a 2455 error. It never hurts to be meticulous, so doublecheck that you've got the name of the subform's control on the main page and not the name of the form itself. If the names are correct, it should be working fine.

I also tested referencing subform controls from different tabbed pages, and it seems to be easy enough. All subforms are available in the main form's controls collection, regardless of which page they reside or which tab is active. They're also available in the Controls collection of the Page in which they reside, but it's probably not necessary to reference them this way. However, the Controls collection property from a Page or Subform object cannot be referenced implicitly, so you'll have to reference your controls explicitly like so:

Forms!NameOfMainForm!NameOfSubformControl.Controls("NameOfControl")
or...
Forms!NameOfMainForm!NameOfPage.Controls("NameOfSubformControl").Controls("NameOfControl")