SubForms

  • Thread starter Thread starter Dwight
  • Start date Start date
D

Dwight

Can a SubForm be created using VBA? I have a form with a
TAB control that has sub forms on each page of the tab
control. Because of performance I want to remove the sub
forms and add them with an event procedure when the page
becomes active.

Thanks in advance!

Dwight
 
Dwight, you cannot create the subform controls without switching to design
view.

However, you can leave the blank (i.e. nothing in the SourceObject
property), and then use the Change event of the tab control to assign the
name of a form to the SourceObject property. You do have to handle the
LinkMasterFields/LinkChildFields, but that's not problematic unless based on
a complex key.
 
Dwight,
I'm not sure if I understand correctly, but I will give
it a try. I have a ton of sub form use in my program.
When loading the main form you can specify a filter from
either the previous page's code, in the properties of the
current page, or you can create it in your event
procedure. You have to make sure the record source
properties coincide on the main form and the sub form
control properties. The sub form has two sets of
properties. One as a control of the main form, and the
other is for the sub form itself. You get the properties
of the sub form control by selecting it within the main
form. You get the sub form properties by select the
corner sqare in the upper left. Within the sub form's
properties you have master and child field links. These
are your main connections. Then each sub form control can
be linked to your specific field of the table with its
record source property.

Loading these sub forms can be performed in any event
procedure and the links will remain saving you a lot of
code writing.

Hope this helps,
Scott
 
Thank you!
I was afraid of that. Leaving the SourceObject property
blank does help improve performance from loading in 30
second to 5 seconds. That will help a little as I move
into a WAN enviroment. A whole different issue......

Dwight
 
Back
Top