Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS Access How can I refresh a form in datasheet view?

Posted on 2013-01-30
3
Medium Priority
?
2,125 Views
Last Modified: 2013-01-30
I have two forms - one in datasheet view and one in regular form view with details.

I created a button to add a new record using the form with details.

Problem: After closing the detail form the datasheet form is not refreshed and doesn't display my new record.  How can I avoid a manual refresh of the datasheet?
0
Comment
Question by:DJPr0
3 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38835733
You just do this in the form_close event procedure of the regular form.

Forms!Datasheetformname.Requery
0
 
LVL 49

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 38835738
You cannot simply refresh the datasheet, as the refresh method will only reflect changes in the current recordset, not additions.

You will need to use the Requery method.  How are you closing the details form?  I would generally do something like:

1.  Have a Save/Close button which is used to write the current record and close the details form.
2.  In the Click event of that button, after saving the record, I would record the primary key associated with that record.

      lngAddedRecordID = ??

3.  Then I would requery the other form

Forms!OtherFormName.Requery

4.  Then I would use the FindFirst method to set the record pointer to the record that was just added, something like:

    With Forms!OtherFormName.RecordsetClone
        .FindFirst "[PKField] = " & lngAddedRecordID
        if not .nomatch Then
            Forms!OtherFormName.Bookmark = .Bookmark
        endif
    end with
0
 

Author Closing Comment

by:DJPr0
ID: 38836378
Thanks fyed
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question