Tab Controls - List Boxes and RowSource queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All

Hopefully a simple question for this one although I have been staring at it
for days now.

I have a form which uses a Tab Cotrol with lots of Tabs which have attached
list boxes. I have created these an populated the Row Source attribute and
the list boxes all display the results I expect.

The Form however takes forever to load and the user doesnt always require
access to all the Tabs. Can I use vba to only execute the query and fill the
List boxes if the Tab is Activated and put in context.

I believe this will reduce the load time of the Form and make the entire
process more efficient

All help gratefully appreciated
 
I had the same problem a couple of years ago. Mine wasn't tabs, but there
were 8 list boxes used for filtering a complex report.
What I did was leave the row source property of each list box blank. Then
when the user selects the tab, use the tab's Click event to set the rowsource
property of the list box.

It will make a dramatic difference in load time.
 
Dave Thanks for the update

However I am struggling to get the click event to work as you have suggested
although strnagely enough works if I create a click event on the list box.

My code is

Private Sub tabHomeEmployee_Click()

Dim strDept As String

strDept = "SELECT * FROM EMPLOYEE LIST WHERE DEPARTMENT = 'HOME'"
Me.List87.RowSource = strDept
Me.List87.Requery

End Sub

Any Suggestions for the dim of thinking at this time in the morning would be
appreciated
 
Dave

Eventually used the On Focus Event and it works as you prediceted

Many Thanks once again for you assistance
 
Each page (tab) has a click event. I have used this technique before, so I
don't know what the problem is.
IMHO, if you could get it to work properly, it would be better cosmetically.
Now, they have an empty list box when they go to a tab.
 
Yes, each Page has a Click event, so does the TabControl, but they aren't
very useful. Page_Click only fires if you click in the non-tab selection
area of the page and TabControl_Click only fires if you click on an empty
area in the tab selection area. Neither fire when selecting an existing
Page.

If the idea is to capture when any particular Page is selected, use the
Change event of the TabControl. At that point, test TabControl.Value (which
represents the newly selected Page) within a Select Case structure and
set/requery the appropriate Rowsource.

HTH,
 
You are correct, George.
I was mistaken about when the click event fires. Guess I was remembering
something different.
 
Back
Top