Update form from other form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kBlack
    New Member
    • Jun 2010
    • 2

    #1

    Update form from other form

    Hey,
    I have two forms in microsoft access. One of them (add form) is supposed to create a new entry into a table. The other form (edit form) is supposed to allow you to edit the entries of the table. I am having difficulty making this work properly. The edit form will only work for the original members of the table, not for any of the entries that were added using the add form. The add form works by allowing the user to input the data and then click a button called add entry on the form. This should add the new entry into the table and allow it to be accessed using the edit form. This is not happening though. Is there any way I can do this?
    Thank you
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Are these two forms working in tandem? I mean to you click a button on the edit form to launch the add form and then close the add form when you are done adding? Something like that?

    If that is what you are doing, make sure you put this code in before you launch the add form
    Code:
    if me.dirty then me.dirty = false
    That will make sure the record being edited is written to disk and no longer locked.

    Also, after the addition is done, you'll want to force the edit form to do a requery. That will update the data set for that form. You can do that from the add form with Forms!nameOfEdi tForm.requery. Then when you close the add form the edit form will have the new record(s).

    Jim

    Comment

    • kBlack
      New Member
      • Jun 2010
      • 2

      #3
      Thanks Jim,
      The two forms work together but neither form calls the other. The add form will create a new record/entry that should be added to the edit form. For some reason, this is not happening. The add form will add the new entry to the main table, but the edit form does not change. How could this be fixed?
      Thanks

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        You need to requery the database. Depending on your system option settings, you might have a toolbar option to do that. It will be under the Records pull-down menu, "Refresh."

        Or just add a little code to the Add form, so after it adds a record to the database it does a .requery on the other form.

        Jim

        Comment

        Working...