Window Name as variable

I have saved the last window each user had open when he logged Out/Quit. When the app starts and the user logs in, I get the name of the last window he had open and I want to re-open that automatically.

sWindowToOpen = rsRecall.Field("LastWindow").StringValue if sWindowToOpen <> "" then sWindowToOpen.Open

Obviously the above code won’t work. So how do I cast a string variable as a window to be opened???

You can’t do that this way. Windows don’t exist until they are instantiated.

Use a select case such as

[code]select case sWindowToOpen

case “Window1”
Window1.show
case “Window2”
Window2.show
end select[/code]

This is admitting the windows have implicit instantiation.

Instead of storing the name of the window, you can store its title.

That’s what I was afraid of Michel. It’s just going to be a very long select case.

On the Mac this should be possible automatically with this window restore functionality that I kill on my computers. If you are on Windows I would try to use introspection. And ditch the implicit instance.

Problem is with the Mac restore window, is that it launches the app, but the specific window state restore falls on the programmer.

On Mac and Windows, I don’t think it is possible to use Introspection to access the windows, implicit or not, when they are not instantiated first.

Already written and tested the SELECT CASE as described by Michel. It’s fairly long, and likely to grow longer, but it works just fine.