• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 706
  • Last Modified:

Run-time error '2450'

I'm loading a form from another form (Main_Menu) using this code attached to a button event:

Me.Visible = False
DoCmd.OpenForm "Module_Menu"

This works well, but when exiting the form, I have code attached to another button to close out and return to the main menu (simple enough supposedly):

Forms!Main_Menu.Visible = True
DoCmd.Close

At that point I get the run-time error '2450'  Access can't find the form 'Main_Menu' referred to in a macro expression or Visual Basic code.

Hopefully it's a simple fix--yet it's become very frustrating.

Thanks in advance for your assistance....
0
dhjensen
Asked:
dhjensen
  • 4
  • 4
3 Solutions
 
Rey Obrero (Capricorn1)Commented:
do a compact and repair of the db.

then from VBA window, do
Debug >Compile
correct any errors raised

test
0
 
Rey Obrero (Capricorn1)Commented:
also check if name of the main form "Main_Menu" have an underscore or a space,
if a space you need to enclose he name in brackets

Forms![Main Menu].visible=true

0
 
Jeffrey CoachmanCommented:
also make sure to carefully check your spelling of these names in your actual db.
Main_Menu
Mian_Menu

This is a common error with mis-spellings...

Also make sure there is no code anywhere that actuality closes the Main Menu
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
dhjensenAuthor Commented:
Compacted & repaired database, and compiled.  Made a few corrections, but still having the same issue.

I'm going to export the form, delete it, compact db, and re-install the form.  I'm open to any other thoughts....
0
 
Rey Obrero (Capricorn1)Commented:
can you upload your db..
0
 
dhjensenAuthor Commented:
Unfortunately not.
0
 
Rey Obrero (Capricorn1)Commented:

try this codes

create a global variable in a regular module

public CalledBy as string
------------------------------

from the main form, opening the other form

Me.Visible = False
DoCmd.OpenForm "Module_Menu", openArgs:=Me.name



in the load event of form "Module_Menu" place this codes

private sub form_load()

if me.openargs & ""<>"" then
  CalledBy=Me.OpenArgs
end if

end sub


in closing the form "Module_Menu" , use this codes

Forms(CalledBy).Visible=True




0
 
dhjensenAuthor Commented:
OK, reversed the lines in the exit buttom from:

Forms!Main_Menu.Visible = True
DoCmd.Close

---to---

DoCmd.Close
Forms!Main_Menu.Visible = True

and it works now.

Apparently, the Main_Menu was "visible" just behind the existing screen, and probably had focus, and was probably closing (couldn't see it so it's hard to tell for sure).  

The error 2450 happened after pressing the button again (nothing was appearing to happen.)

I'll split the points for your assistance.  It's very much appreciated.

In the mean time, I'll kindly accept the Dumb*** of the Week Award--thankfully, it's Friday.
0
 
dhjensenAuthor Commented:
Thanks for the assistance!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now