Results 1 to 6 of 6
  1. #1
    JohnnyChance is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Posts
    3

    Runtime Error 2489 - Object not open

    I have been working on a database to track ForkLift usage in the warehouse. I had created several Add forms to handle adding in different information. Inside of each one I have them limited by having Data Entry = yes, and I have a button on the form to save the record and then go to a new record. The button seems to be working to save the record but when going to the new record it gives me "Runtime Error 2489 - Object not open". I was using a macro to do this with

    RunMenu Command - Save REcord

    GoToRecord - Object Type Form
    Object Name frmVendor_Add
    Record - new

    In an attempt to change it and try to make it work I switched to VB code.

    Private Sub btnSave_Click()
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord acDataForm, "frmVendor_Add", acNewRec

    End Sub


    I am still getting the object is not open with both. These forms were all working a few days ago. I am not sure if I have changed an option that caused this or something else.

    Thanks for the help.

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Is the code you show in the frmVendor_Add (module)? You need to open the form first before you navigate to a record. And if the form is in data entry mode you don't have to specify new record.

    Cheers,
    Vlad

  3. #3
    JohnnyChance is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Posts
    3
    Yes, the code was in the frmVendor_Add module. I have a navigation form that I use for control and the frmVendor_Add is a subform of it. Even with only doing a save record command once they click the button the form would not go to a new record. It would stay on the same one. I am still at a loss as to why it would work one day and not the next. I did some more research and did discover 2 ways to make it work.

    First way:
    Private Sub btnSave_Click()

    If Me.Dirty Then
    Me.Dirty = False

    End If

    DoCmd.GoToRecord , , acNewRec

    End Sub

    Or 2nd way:
    Private Sub btnSave_Click()

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord , , acNewRec

    End Sub



    Thanks

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I'm thinking that a macro can resolve the path to a form on a navigation form (because you click to it) but to do this in vba requires 2 things:
    - that the form to be affected is the same form as the event is on because it spite of how it looks, a nav form only loads one form at a time
    - that you use Me or if not required, no form reference because the nav form adds extra layers to the reference "chain". I would not expect your form reference could be resolved when it's on a nav form. Not 100% sure because like many, I avoid nav forms and macros.
    Last edited by Micron; 06-12-2019 at 01:46 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    JohnnyChance is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Posts
    3
    This is the first big Acces project I have ever done so I am stll learning. I am trying to lean VB as I go, hence the reason I tried the macros first. The code above seems to have fixed my problem. Can you guys suggest a website to help me with VB and Access learning. I have used access in the past to cross reference info but never to the extend of the user interface that I am doing now.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Orange frequently post links to Steve Bishop (I don't have them) so you could try searching that or ask google the same basic question. There must be thousands of sources, some which you relate to better than others, some bloated with ads and such annoyances, so it's largely a matter of personal preference. You can learn from converting macros to vba but you'll end up with a lot of code drivel that you don't want to pick up as habit.

    Unfortunately vba is really enmeshed in Access itself, meaning knowing how to code for an event is only part of the challenge. Much of the time you need to understand why you need one event over (e.g. Open vs Load) and where it may fit in a chain of events. You might find this bible a valuable reference going forward. A bit technical and sometimes the examples are lacking, but I probably refer to it every day. One reason for that is there's a lot of stuff you won't find on a property sheet.

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

Similar Threads

  1. Error 2489 object isn't open.
    By Leonel in forum Access
    Replies: 4
    Last Post: 01-23-2018, 03:49 PM
  2. Runtime 424 error... Object required.
    By sanderson in forum Programming
    Replies: 8
    Last Post: 08-09-2015, 08:10 PM
  3. Runtime Error 424 Object Required
    By Maltheo2005 in forum Programming
    Replies: 9
    Last Post: 06-13-2013, 04:52 PM
  4. Replies: 13
    Last Post: 06-12-2012, 09:52 PM
  5. Replies: 3
    Last Post: 04-15-2010, 09:43 AM

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