Help! Need to clear "List Box" value after selection

esurfer

Registered User.
Local time
Today, 17:01
Joined
Jan 29, 2002
Messages
12
I have 2 list boxes that are synchronized. The idea is for a user to select an item in the first list and then select an item in the second list (if there are any.) I have this part working. The user then presses an "Edit" button to open the record that the selections refer to. The problem I have is when the user selects an item in the first list and the second list contains no items. When the edit button is pressed, the last item that was in the second list is used, rather then an error message occuring indicating that the second list value is missing.

The error message does occur if a prior selection has not been made.

The question I have is how do you clear the value that is stored in the ListBox so that it is null. So when a user presses the "Edit" Button if the second list box is empty they will get an error message and the previous value will not be used.

Thanks,

esurfer
 
Dim frm As Form
Dim VarItm As Variant
Set frm = Me
Dim ctl As Control

Set ctl = frm![ListBoxName]

For Each VarItm In ctl.ItemsSelected
ctl.Selected(VarItm) = False
Next VarItm
 
Where does that code go?

Thanks,
esurfer
 
The above code didn't work but I figured it out. All I needed to do was place the following code in the After Update of the 1st List Box:

2ndListBox.Value = Null
 

Users who are viewing this thread

Back
Top Bottom