How to: returning to former window after adding related record

I’m sure this is covered somewhere but I can’t find it.
The situation: A record doesn’t exist in a related db so when I enter it in the current db it looks for code in the record-doesn’t-exist panel. That panel says posttorelated "related db". So far so good, all happens as I expect, the related db comes to the front and a new record is created. (Append is checked on the relation setup panel, and the db’s are related in both directions.)
So how do I automatically get from the related db window back to the window I was working in in the current db? I tried putting the usual wasWindow code in the code-to-run-if-related-record-doesn’t-exist panel, but that just stopped the posttorelated code from functioning at all.
Suggestions gratefully received.

Could you be a bit more specific about what you tried. “The usual wasWindow code” would be what I would suggest, but you’ve already said that doesn’t work.

Problem solved. I realized that my wasWindow code had set wasWindow as a local rather than a global variable, so of course the related db had no idea what I was talking about. Duh. But it is reassuring to know that there are no particular restrictions on what code can go into the record-doesn’t-exist panel (other than that it make sense…).

Ok, now that the basic problem is solved, I have a suggestion. I haven’t covered it in the sessions yet, but Denali has a new feature that allows you to work with window numbers instead of names. If you use numbers instead of names, you can avoid the confusion that can occur if multiple windows have the same name (for example a form and a procedure window). There is an example on this page showing how to use this to bring a former window back to the front.

Yes, thanks, I do remember that and have been using it successfully ever since I read about it or you told us about it in the sessions. It’s a great convenience.