Assuming that the list box has its Multiselect property set to Simple or
Extended, put this code on the OnClick event of the list box:
Private Sub ListBoxName_Click()
Me.TextBoxName.Value = -(Me.ListBoxName.ItemsSelected.Count > 0)
End Sub
Be sure that the default value of the textbox is set to 0 so that it will
have your desired value if nothing is ever clicked or unclicked in the list
box.
Now, let me suggest a different approach for your macro. Let it use the
Forms!FormName!ListBoxName.ItemsSelected.Count as its value instead of the
value in the textbox. "Cut out the middle man." And then you don't need to
VBA code on the list box's OnClick event either.
--
Ken Snell
<MS ACCESS MVP>
Mark Senibaldi said:
I have 1 form with a list box on it. The values chosen become criteria in
a query- but I want to use a criteria of * if no values on the listbox are
chosen. I almost figured it out. I put a text box on the same form and I
want a "1" to show up if at least one value is chosen on the listbox, but if
no values are chosen I want a "0" to show up. I'm going to base a macro off
of this test box (use as a condition) any help would be appreciated.