OK all you gurus…
I have a SwitchBoard (Access2007) that I use to launch a variety of other forms in the application. The default views are tabbed forms. That is, when any forms are open, you can see their titles as a selectable tabs in the Access app. |Formname1 |FormName2 |Formname3 … and so on… I also have a special form that I launch from form1 and display as a Popup/modal. When the user exits (Unload event) that popup form, I am trying to set the focus to form3. However, It remains focused on Form1 Any tips, suggestions ? (I have tried setfocus, tried re launching form3) . I’m sure its something stupidly simple that I am overlooking… Thanks Grant
Hi Mary,
The method you suggested does not seem to effect the order in which the form’s focus occurs. ( I did try it)
Part of the problem I think… is that Form1 is in fact the Switchboard form. In any case, the user has to manually toggle between that form and any other form that is opened. (The exception being those forms, which open as model/popup).
As i wrote before, the work around for me was to simply close the switch board and open the other form, when I close my modal form.
Thanks for your inputs
Grant
Hi Grant
When the popup form closes control passes back to the code that launched it. Can you put the code to control which form is on top in this code ie after the openform command that opens form3 not in form3’s close event?
Mary
Joey,
I see now what you are saying.
However, the solution you described is not what I 'm haveing trouble with.
To see what I mean, try the following:
Once Form1 and Form2 are open, launch a form3 (modal + Popup).
From form3’s close event, try to toggle between Form1 and form2 Zorder; that is, try to manipulate which form’s view prevails on top. You will discover that it can’t be done in any conventional way as long as form1 and form2 are not popups.(even when attempting to use setfocus on a specified control.
I figured out a work around. My form1 launches form3. When I close form3 , I close Form1 and launch form2. Its the best I could come up with. The whole point of the exercise was to give the user direct access to Form2 after successfully completing the tasks in form3. I guess this will do for now…
Thanks for your help
Grant
Grant, I’m not thinking of child forms embedded in a tab control. I built and tested the approach that I suggested, and it works for me…
I built a form (form 1) with a tabbed control with two tabs. Tab 1 contains a text field (field 1) and Tab 2 contains another text field (field 2) and command button (button 1) that invokes a modal form (form 2) which has a command button (button 2) which closes that form.
With form 1 open and showing the contents of tab 1, I click button 1 and it opens form 2. When I click button 2, form 2 closes and form 1, tab 2, field 2 gets focus and is displayed.
Joey
Joey,
I think you might be referrring to child forms embedded in a tab control? If so, those can be referenced as Page names (or child object (index#))
But in my case, I’m trying to swap between (views) of two main forms. (Switchboard / Form1)
I am trying to invoke the swap from Form2 (a modal popup). When I exit form2 (close event) I tried setting focus on a command button in form1. Still no luck. The control itself gets the focus okay, but the form1 rests ‘behind’ the switchboard form and the user has to manually select its title tab to bring it forward to view. In VB6 , these forms had what was called a Zorder property, But no so in VBA access
Thanks
Grant
When you close a form, the following events occur in this order: Unload ? Deactivate ? Close. I suggest you put your setfocus in the Close event. There’s one other thing…you don’t want to set your focus to the TAB - you want to set it to the first field displayed on that tab. Setting focus to the tab control will not display the tab, it will only set the focus to the item on the tab control that, when clicked, displays the page you want. All the tab thing really does is allow you to overlay regions of a page on top of other regions - sort of like layers on an HTML page. All the controls are really on the form.
In other words, make a close event like this on your dialog form:
Private Sub Form_Close()
Forms![form containing tabs]![field on tab 3].SetFocus
End Sub
Where are you trying to set focus, relaunch from?
Mary