Clearing ListBox then requery

steve1111

Registered User.
Local time
Today, 17:16
Joined
Jul 9, 2013
Messages
170
Hi I have two list box that control 5 subforms. i have a Run button that works in sorting the subforms according to the listbox. I have a rest button that i want to clear the selections of the listbox and then requery the subforms as if the criteria were null - or return all records. i have the selections clearing, it is just my forms are not "going back to all" on the requery. i have little to no code experience. thank you!

Private Sub Command62_Click()
Dim varItm As Variant

With clinicLbx

For Each varItm In .ItemsSelected
.Selected(varItm) = False
Next varItm

End With

With Division_Lbx

For Each varItm In .ItemsSelected
.Selected(varItm) = False
Next varItm
End With

With Division_Lbx
Me.Filter = ""
Me.FilterOn = False
End With

With [Forms]![MapPoint Report Form]![mp clinics over subform].Requery
End With

End Sub
 
If the subforms are filtered according to the list boxes, then clear the subforms filter. Look at the code for the listboxes what happen when you select an item and do the opposite.
Then you've some unnecessary With - End with in your code.
Example:
Code:
With [Forms]![MapPoint Report Form]![mp clinics over subform].Requery
    End With
Look in the Help file for explanation how and when to use With - End with statement.
 

Users who are viewing this thread

Back
Top Bottom