Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form won't open - Bug or Bad Code? 1

Status
Not open for further replies.

jkestes

Technical User
Nov 10, 2014
10
0
0
US
I have a database with some employee information. There is a Main Menu that starts when you open the database and it has a bunch of buttons you can click to open other forms and reports. Once you are finished with a form, you can press a button that closes the form and returns you to the Main Menu. All the buttons work fine (using macros) except for one particular button on one form. I have tried using a macro and have now tried using the code listed below. Is this some kind of bug I am unaware of or is there a flaw in this rather simple code?

Private Sub btn_ReturnToMM_Click()
DoCmd.OpenForm "frm_MainMenu"
DoCmd.Maximize
DoCmd.Close ObjectType:=acForm, ObjectName:="frm_Edit Employee Info"
End Sub

BTW - the three steps I want to accomplish are 1) close the active form, 2) open the Main Menu form and 3) maximize the Main Menu form so that it fills the screen.

Like I said, I usually perform this function with a macro associated to the button. Here is what the macro looks like...
CloseWindow
Object Type: Form
Object Name: frm_Edit Employee Info
Save = Yes
OpenForm
Form Name: frm_MainMenu
Window Mode: Dialog
MaximizeWindow

Thanks in advance!
Jeff
 
Doesn't frm_MainMenu stay open all the time? If so, you shouldn't attempt to re-open it.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
No, I want the current form they are using to fill the screen so I only keep the current screen open. When they select a new form to use, the macro that opens the form also closes the main menu. It is the reverse of the code in my initial post. I suppose I could change all the macros to leave the Main Menu open, but that still doesn't help me resolve why it won't function correctly.
 
You aren't opening the form MM form in acDialog

Code:
DoCmd.OpenForm "frm_MainMenu",,,,,acDialog


Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks for the corrected code, Duane, but it still didn't resolve the issue. No matter how I tell it to open the Main Menu screen, it won't. I can't find anything unique about this form that would cause it not to work with the macros when I have about 2 dozen other forms using essentially the same macros and they work find.

As a work around, I am just going to take your advice of not closing the Main Menu and letting it sit in the background. Now that I think about it, when I first started with Access about 20 years ago using the 97 version, I got into a habit of only having one form open at a time because of some bug back then and while the issue is resolved, I just never changed my habit.

Thanks for your time, Duane.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top