OK I got it. And there were several issues to solve. Not sure if this is the best way but it does work.
The first problem is to be able to refer to the form you want to have focus from some other form. I overloaded the ‘show’ event for both Form B and Form C to be able to pass the original calling form. When I called Form B from Form A, I supplied a reference to Form A. Then when I called Form C I passed the reference to Form A again. At that point both Form B and Form C knew who the originator was.
I tried to set the focus back to Form A within Form C. So in both Form B and Form C, I would set a variable (Dim ‘callingform’ as Form). In each of Form B and C I used the following:
Dim callingform as Form
Overloads Sub Show(ByVal f1 As Form)
Callingform = f1
So each of Form B and Form C had a reference to the original Form A that was to eventually get the focus.
But you can’t refer to the form with that variable. The following is a proper reference to the form and ‘focus’ is the method to change focus.
CType(callingform, windows.forms.form).focus()
That statement seems straightforward enough but I was trying to use it in the wrong place. I was using that statement at the end of the ‘Load’ event for Form C. The problem there is that Form C hasn’t yet gotten focus so executing that statement would be subsequently overridden as Form C was actually displayed. I didn’t know then but do now, Focus isn’t transferred to the new form until AFTER the load event. So if you put that statement in the Form C ‘GotFocus’ event it works like a charm.
After considering things for awhile, I’ve decided that Form C might be called from anywhere and it shouldn’t be deciding where focus should be set. It should be decided by whoever decided to Display Form C.
So I have put the following in the end of Form B’s Menu selection code:
FormC.Show(formA) ‘Display Form C and pass the originating form)
CType(formA, windows.forms.form).focus() ‘Change focus to FormA, the originating form
formB.Close (actually - me.close) - ‘ Close up the menu form, FormB
(Aside: I don’t really understand why the ‘ctype’ is necessary. I passed the form as a ‘form’ and defined the variable ‘callingform’ as a form. I expected to be able to just say callingform.focus(). )