Dec 8 2006, 10:57 AM
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?
Dec 8 2006, 11:41 AM
DoCmd.Close acForm, "NameOfFormToClose"
Dec 8 2006, 12:06 PM
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....
Dec 8 2006, 12:32 PM
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
DoCmd.Close acForm, frm.Name
Dec 8 2006, 12:37 PM
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....
Dec 8 2006, 12:58 PM
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...
Dec 8 2006, 01:21 PM
Thanks, that is what i was thinking.
Dec 8 2006, 01:50 PM
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!
Dec 9 2006, 10:38 AM
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.
Dec 9 2006, 11:53 AM
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....
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here