Full Version: Making a form the "active" form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
TheOtherDodge
I have a form with a button that opens another form and hides the first form. The custom menu bar "close" option will not work for the second form. Reading the help, if you dont specify which form to close, it "will close the active form". Apparently, to the macro the menu bar is made from, it thinks the hidden form (form1) is still the active one. How can I change this to the second form?
Jack Cowley
DoCmd.Close acForm, "NameOfFormToClose"
TheOtherDodge
I want the custom menu to be universal so i dont have to keep making new custom menus so everytime a new form is open, a new menu bar has to be associated with it. That is why I don't want to specify which form to close....
Jack Cowley
If you don't specify a form how will Access know which one to close? How about closing the form when you open the new one instead of just hiding it? I do not know if something like this will work as I have not tried it:

Dim frm As Form
Dim a As Integer

For a = 1 To Forms.Count + 1

For Each frm In Forms
If frm = screen.activeform Then
'do nothing
Else
DoCmd.Close acForm, frm.Name
End If

Next frm
Next a

Jack
TheOtherDodge
Thanks Jack, I will try your code later.

Let me ask though...is there any benefits to hiding vs closing? Assuming there is not a lot going on when a form is closed/opened....
Jack Cowley
I am not aware of any benefit of hiding vs closing unless there is a TON of stuff going on with the form and it takes some time to load. In that case hiding is obviously better then closing...

hth,
Jack
TheOtherDodge
Thanks, that is what i was thinking.
Jack Cowley
You are welcome... What a lot of us do is have all our forms open maximized. A new form is then opened and covers the previous form. When the current form is closed the previous form is displayed, which is generally the form you want to see. This way most forms stay open all the time but are unseen as they are behind the current form.

Good luck with this!

Jack
TheOtherDodge
Jack, the reason I want to keep other forms on top of the previous forms is because they are small. IMO, they would look stupid with the screen maximized, and then I would have to worry about multiple resolutions.

Look at my attachement and you will get a better idea. I would like the form that is the last to be open (on top) the one to be able to use the menu bar to print, etc. I can't get that to work right now, especially when a report is opened to preview.

Thanks.
Jack Cowley
TOD -

I don't quit understand your question, but if your top form is opened as Pop Up and Modal then you can't click on anything until that form is closed.

Does that help? Also, I am off to another job shortly and I will not be back in the UA building until tomorrow. If we get rained out today I may be back this afternoon, but don't count on that....

Jack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.