You can't lock a control while it has unsaved changes

C

cmw

On the click event of one listbox (ListA), I call a routine that determines
which controls on the form should be available for editing. If a control
should not be available and contains data, the control is cleared then
locked. Works on everything but a second listbox (ListB) including a 3rd
listbox (ListC).

First, I select item 1 to return the list to the top most position and to
unselect
the selected item if any. Then, I set unselect it and lock it.

ListB.Selected(1) = True
ListB.Selected(1) = False
ListB.locked = true
--> Error Msg

If I don't perform the select, I can lock and unlock the control at will. It
will not allow me to move the focus to ListB or any other control.

I have a 3rd listbox (ListC) which I empty and lock. That works fine

Do while ListC.ListCount > 0
ListC.RemoveItem(ListC.Listcount -1)
loop
ListC.locked = true

Thanks for your help
 
K

Klatuu

You are doing two different things to the list boxes.

For this one:
Do while ListC.ListCount > 0
ListC.RemoveItem(ListC.Listcount -1)
loop
ListC.locked = true

You are removing all the data in the list box. Therefore, there is not data
in the control so it can be locked. This assumes ListC is a bound control;
otherwise, it would make no difference.

In this one:
ListB.Selected(1) = True
ListB.Selected(1) = False
ListB.locked = true

You are makeing the 2nd item in the list selected, then you are making it
unseledted and no data is removed.
 
C

cmw

I realize that I'm doing 2 different things in the list boxes. My goal is to
lock both of them. I can lock ListC (the remove item one), I can lock the
other one (ListB), but only if I don't select/deselect an item.

ListC is not bound, it's populated by the double click event on ListB .
ListC isn't bound to a field, but it's filled with a query and the data does
not change. The action of double clicking selects an item and leaves it
positioned. I'm just trying to return it so it appears as it does when the
form loads.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top