Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple SubForms

Status
Not open for further replies.

DH

Programmer
Dec 8, 2000
168
I have a main form with 4 subforms on it. When the form loads I would like to display subform1 and hide the rest.

I can do this using Me.subform2.visible=false, etc. on open.

My issue is that the underlying query of each subform is somewhat lenghty and time consuming. Therefore, I do not want to load the query of each hidden subform when the main form is opened.

Four command buttons are present on the main form so that the user can change between subforms. For example, when the user clicks the command button "subform2" I would like to then open subform2 and close any of the remaining subforms that may be open.

Any suggestions on how to accomplish this??

Is there a command or event or something that I can tell the main form to only load subform1 on open and not any other subforms? Then when the user clicks a command button I can unload the subform they are currently on and then load the corresponding subform associated with the command button that the user clicks.

Thanks


Thanks
 
DH

I don't know whether this will help or not but try looking into the use of SourceObject for your subforms. If you set the subForm's SourceObject to be "" when not in use and equal to the subform's Form name when in use.

Maybe it will work.

I have never tried it.

Please tell me how it goes on

*
***
*****
*******
Ziggurat
 
Ziggurat is correct, the record source statement should sort this out.

Here is what to do.

In Design view
1. Place the subforms on the main form.
2. Ensure the source object in the properties of this subform is empty.
3. Set the visible property of the subform to False.

The button the user clicks should trigger code to:
1. Set the record source for the form,
Me(SubFrmName).Form.RecordSource = "select * from " & strRecordSource & ";"
where strRecordSource is the query that the holds the data to view.
2. Set the visible property of the subform to True.

I think this should do it.

Good luck
 
I did not understand the other 2 replies 100% but I know your problem and it is actually covered by the Access manuals - Building Applications and Users Guide. Look under optimization techniques.
Basically you are better off hiding the subforms rather than closing them especially if they take a long time to load up. There is a principle of opening up most of your forms at the start of the programme and setting those you want to use to visible = true and those not in use to false. Using visible/invisible is apparently more efficient.
Hope this helps a bit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top