Opening instead of closing???

I have a ListBox which contains a contextual menu. When I use the code below - all works perfectly. It closes certain windows if they are open, and opens the window selected by the user.

[code] Select Case hititem.text
case “Add a New Choice”
case “Edit or Delete the Selected Choice”
case “Search Choices”
case “View All Choices”
End select

Return True[/code]

HOWEVER - the impossible seems to happen when I add the code below to the 1st, 3rd and 4th Cases.
It causes ALL of the cases to OPEN the “win_Edit” window - instead of closing it, and opening the appropriate window ???


It seems impossible and I am totally perplexed.
Can anyone shed any light or ideas?

Thank you all in advance.

Sounds like a side-effect of Implicit window instantiation which allows you to refer to your windows directly by their name. Although convenient, it can lead to this confusing behavior as projects get more complex.

You’ll instead want to create your own instances of your windows (like you would for any other object) and deal with the windows that way.

So something more like this:

Dim editWindow As win_Edit editWindow.Show

Then to close the window you can call:


Bit confused as I am only a part time user :frowning:

So I need to de-select the Implicit instance in the inspector.
Then add the first section of code you provided.

Also, should the last piece of code you kindly provided be editWindow.Close ?

Thank you for your patience. :slight_smile: