List Boxes and Multiple Tabs not Updating

Pisteuo

Registered User.
Local time
Today, 10:48
Joined
Jul 12, 2009
Messages
72
I have 4 tabs with a list box in each. Each list box executes the same query On Click. This query populates a SECONDARY list box. So 4 independent list boxes update 1 query that populates 1 list box.

By opening the query after I click on each list box I can see that the code executes properly for all 4 list boxes. However the SECONDARY list box only populates based the 1st of the 4 list boxes within the tabs. When I click on the second list box, I can see that the query executes properly but the SECONDARY list box stays empty. The same problem happens with the 3rd and 4th list boxes within the tabs.

Code:
Private Sub lstCompetencyOne_Click()
Me!lstDeliverable.Requery
End Sub

Private Sub lstCompetencyTwo_Click()
Me!lstDeliverable.Requery
End Sub

Private Sub lstCompetencyThree_Click()
Me!lstDeliverable.Requery
End Sub

Private Sub lstCompetencyFour_Click()
Me!lstDeliverable.Requery
End Sub

Code:
SELECT qryTasks.[CompetencyID], qryTasks.[DeliverableID], qryTasks.[DeliverableDescription], qryTasks.[Focus]

FROM qryTasks

WHERE ((qryTasks.CompetencyID)=Forms!frmCourse!lstCompetencyOne Or (qryTasks.CompetencyID)=Forms!frmCourse!lstCompetencyTwo Or (qryTasks.CompetencyID)=Forms!frmCourse!lstCompetencyThree Or (qryTasks.CompetencyID)=Forms!frmCourse!lstCompetencyFour);
 
First up - you should be using the control's AFTER UPDATE event and not the click event.
 
This is my third or fourth time looking at this thing, trying to figure out what you're trying to do here! Bob is correct, of course, the proper event to use to base an action on a ListBox selection is its AfterUpdate event, not the OnClick event. The user may simply click on the ListBox in moving to it, without meaning to actually make a selection.

But why are you using four separate ListBoxes, on four Tabbed Pages, to execute the exact same Query? Seems like a waste of real estate, to say nothing of creating extra work for your users. What exactly are you trying to do? If you want to select multiple values for your WHERE clause of your Query, that can be done with a single ListBox, using its Multi-Select Property and code.

Linq ;0)>
 
That worked. Thanks.

I wrongly assumed that AfterUpdate would not work because the list boxes are unbound.
 
linq,

I see now why On Click didn't make sense. Thanks for the explanation.

The tabs represent different record levels. One of the 4 tabs will have priority for the user. Based on user input, either tab 1,2,3, or 4 will be indexed. The user can then choose from the other tabs if so inclined.
 
Using OnClick is a common mistake for newbies, as is using OnChange. The former, for the reason given, the latter, which should also be replaced with the AfterUpdate event, because it fires every time a character is entered in the Control, not when the user is finished entering data.
 

Users who are viewing this thread

Back
Top Bottom