Results 1 to 12 of 12
  1. #1
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55

    Question 2450 Error and How to Error Trap it

    New to the Access Forums and so excited to see such a support forum while I am working through learning Access.

    Working with an old Database built in Access 2003 (and potentially before then). Now working in Access 2010 and trying to clean up and spruce up the database.

    Error:



    When I close the database and the frmMenu is not visible, I get the error - Run-time error '2450': [DatabaseName] cannot find the referenced form 'frmMenu'.

    When I close the database and the frmMenu is visible, it closes fine!

    Question:

    1) Can I just error trap that error and ignore it? I read this post and it's what they suggested: https://www.accessforums.net/program...0-a-35162.html but I don't know where to put the error trapping code they suggested from here http://www.baldyweb.com/ErrorTrap.htm

    OR

    2) What should I be looking for in the VBA that is causing this issue?

    I have tried looking for anyting to do with closing or quiting and everything looks fine, I have also tried looking at all frmMenu references and they all look fine. I can't debug because when I click debug, the program quits.

    Any help is greatly appreciated!

    Robb

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    There is code (macro or VBA) somewhere that is referencing frmMenu but shouldn't matter if it is visible or not (unless maybe code is trying to return focus to frmMenu). Is frmMenu actually already closed?

    Best to find the code and fix.

    How are you closing the db - the X close or button on another form?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    Last edited by June7; 09-24-2014 at 05:51 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If you have that same problem, mine was in a reference in the load event of a main menu that was looking for a login form. I added a Case to the load event's error handler:

    Code:
    ExitHandler:  
      Exit Sub
    
    ErrorHandler:
      Select Case Err
        Case 2450
          'strange error of form load code running on quit
          DoCmd.Hourglass False
          Resume ExitHandler
        Case Else
          MsgBox Err & Err.Description & " in Reservation Form_Load "
          DoCmd.Hourglass False
          Resume ExitHandler
      End Select
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post

    ...Is frmMenu actually already closed...
    That was going to be my guess, that 'not visible' actually meant closed.

    Quote Originally Posted by pbaldy View Post

    ...a reference in the load event of a main menu that was looking for a login form...
    I've actually seen this problem (a Form_Load event firing when a database was closed) a number of times, here or elsewhere, but have never seen an explanation of why it occurs. It could be something like this, but I agree with June7 that the OP ought to try to find the offending code, if at all possible, rather than simply trapping the error. My guess would be code that, on the closing of one or more Forms, returns the user to the frmMenu Form.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If it's the same situation, finding the offending line of code wasn't that easy. Like Robb, I couldn't step through the code, it just blew up. The only code "running" was a Quit behind a button. If I set a breakpoint there and stepped through it, it didn't lead me to the on load code that caused the error, it just blew up. The load code was somehow running in the background (how is above my pay grade).

    Trapping the error was the only way around it, there was nothing wrong with the actual code (it grabbed the logged in user from the then-hidden login form as the main menu opened). When you quit the application you can't (to my knowledge) control the order Access closes forms. In my case, it was apparently closing the hidden login form before the main menu, thus the load code in the main menu couldn't find it. Why the load code was running is also above my pay grade. I posted in an MVP forum at the time, and nobody could figure out why it happened. One had seen the same problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I have code that first checks if form is loaded before trying to interact with it:

    If CurrentProject.AllForms("DialogSelectLabNumber").I sLoaded Then

    However, this would require finding the problem procedure to edit it. Search for every use of frmMain in the VBA and edit code with either method.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55
    Thank you for all your responses. I did look through all references to frmMenu but none looked to be the culprit (commented them out and also basic knowledge of VBA tells me they weren't trying to call the form on exit).

    I am using the Access "X" button to close. If I use the "X" button while on the frmMenu form, it works fine. If I use the "X" button on say a report, it throws the error.

    There is also a Close button on the frmMenu that works fine (I assume because the only way to click it, is to be on that form).

    Looking through the VBA it looks like whenever you navigate away from a form (to produce a report etc) the frmMenu form is set to hidden (so it's never closed).

    At this point I am not ready to provide the database as it would take loads of work to remove sensitive information. I hope you can understand (I also know this would make life a lot easier).

    I would prefer to avoid trapping but it might be my only option.

    Question: Where do I look for what is being called when the "X" button is being clicked? Is there a close event that all Access projects have? How do I view this?

    OR is there no way to tell what's being called on close with the "X" button?

    Thanks a lot!

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    There is no event for the application X close button. However, any code in any open form or report Close event would be triggered because the application has to close each object.

    I disable the X close on all forms (leave it on reports). I use a custom button for users to close form. I don't use form Close event. I have used report Close event.

    I also have code that disables the application X close.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55
    Ah ok I figured it out, at least the root of the problem and I think June7 might have the solution.

    Basically the navigation of the forms works like this.

    When I click a button to open a new form (to input data or to run a query) it uses Me.Visible = False and launches the new form. When the form is closed it calls frmMenu Visible to be true.

    The issue is, when I use the application X, it must be calling that form but I guess it's been closed before the code executes and throws an error.

    Should I wrap my Visible = True in the suggested, If CurrentProject.AllForms("DialogSelectLabNumber").I sLoaded Then

    Or is there a better way to open and close forms using buttons?

    Thanks a lot,
    Robb

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Code in the Close event or a button Click, probably still need the wrap.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Or trap for the error as described previously.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55
    Quote Originally Posted by June7 View Post
    Code in the Close event or a button Click, probably still need the wrap.
    This is exactly what the issue was, it was trying to interact with the form that was obviously closed before that code ran.

    I used your check to see if the form was loaded first and BOOM no error, works like a charm.

    Thanks everyone for all your help. I am really happy I didn't have to trap the error, I feel like that's a workaround and I want this DB to sing.

    Robb

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-05-2014, 07:55 AM
  2. Run-Time Error 2450
    By dascoli in forum Programming
    Replies: 7
    Last Post: 05-28-2013, 10:49 AM
  3. Trap Error 2476 Code
    By burrina in forum Forms
    Replies: 1
    Last Post: 01-18-2013, 11:56 AM
  4. Replies: 9
    Last Post: 06-08-2012, 07:52 AM
  5. error run time 2450
    By storm1954 in forum Forms
    Replies: 2
    Last Post: 05-11-2012, 06:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums