Tabbed Forms

G

Guest

I have a form that has several subforms on it. It is actually the main form
for the database where all info for individual repair jobs is entered and
viewed. This form calls on a number of queries to open all this info and
with db growth and number of users increasing, we are now looking at speed as
a factor. I'm hoping someone can tell me if using the tab feature to put each
aspect of this form on a separate page/form that user can tab to as needed
will increase speed. Do the tabbed forms still open all the queries or are
they called on only when the tabbed portion of the form is opened?

I hope I've clearly explained what I'm trying to do here. Any help or
suggestions are appreciated.

Thanks in advance,
Pam
 
J

John W. Vinson

Do the tabbed forms still open all the queries or are
they called on only when the tabbed portion of the form is opened?

The Tab Control *ONLY* manages screen space. Otherwise it has no effect on the
opening of subforms.

All your subforms will be opened when the mainform opens.

You can use VBA code in the Tab Control's Change event to dynamically set the
Recordsource property of each subform as its page is opened, but Access
doesn't do this for you automatically.

John W. Vinson [MVP]
 
G

Guest

John,
Thank you for replying. Would you have any sample code you might like to
share to point me in that direction?

Thanks again for your help.
Pam
 
J

John W. Vinson

John,
Thank you for replying. Would you have any sample code you might like to
share to point me in that direction?

Here's one way to do it. This changes the SourceObject of the subforms;
another way is to change the RecordSource of the subforms, e.g.

Me.subWitness.Form.RecordSource = qryWitnesses

You can (and probably should) also set the SourceObject (or Recordsource) to
Null for the other subforms.

Private Sub TabComplaints_Change()
' Comments : Dynamically set Source Objects of subforms on tab pages to
speed form performance
' Parameters:
' Created : 09/21/04 10:26 JWV
' Modified :
'
' --------------------------------------------------

On Error GoTo PROC_ERR

Select Case TabComplaints.Value
Case 2 ' Witnesses
Me.subWitness.SourceObject = "sbfrmWitness"
Case 4 ' Court cases
Me.subCourtCases.SourceObject = "sbfrmCourtCases"
Case 5 ' Restitution
Me.subRestitution.SourceObject = "sbfrmRestitution"
End Select
PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error " & Err.Number & _
" in Form_frmComplaint.TabComplaints_Change:" & vbCrLf & Err.Description
Resume PROC_EXIT

End Sub

John W. Vinson [MVP]
 
G

Guest

John,
Thanks for the code. I'm certainly looking forward to trying it with a
tabbed form.

Pam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top