Open subform only when User wants to?

wrek

Registered User.
Local time
Today, 05:47
Joined
Jun 14, 2001
Messages
88
Hi guys,

I have a subform on my form. But I don't want it to load unless the user hits a button (the underlying query for the subform takes forever to load, plus the data is optional).

The subform currently loads on the Form Load.

I guess I could make it a regular second form opened with a button on the first one....but i want it to have a constant locked position on the first form.

Any suggestions?
 
Hi wrek

How about having a tabbed form with different pages with the subform being located on one of the tabs/pages. You can then set the subform's Source Object to blank (i.e. nothing typed in for that property) so it is an unbound control.

Then put the following in the tab's On_Change Event:

---------------------------------------------
Private Sub tabMyTab_Change()
' Comments : This code dynamically sets the record
' source for subforms. It populates
' the subforms on tabs when the tabs are
' clicked, after checking which tab as
' been selected.'
' --------------------------------------------------------
On Error GoTo Err_tabMyTab_Change

Select Case tabMyTab.Value

'Tests to see if this is the first time the tab was loaded.
Case 1
If Len(Me!frmMyFormSub.SourceObject) = 0 Then
Application.Echo True, "Loading Page, Please wait..."
Me!frmMyFormSub.SourceObject ="frmMyFormSub"
Me.Refresh
Application.Echo True
End If

End Select


---------------------------------------------

This assumes your subform tab is the second tab (with the normal data that you want to load being located on the first tab). The first tab is number 0, so the second is number 1. You can use this for multiple tabs and unbound subforms (hence the Select Case/End Select bit). I have also assumed that your unbound subform has the same name as a control on your tabbed page as the actual name of the separate subform.

Your user will then only load up the subform (with the subsequent time delay for the query to get all the data) if they click on the tab and change to the second page.

HTH

Rich Gorvin



[This message has been edited by Rich@ITTC (edited 07-20-2001).]
 

Users who are viewing this thread

Back
Top Bottom