Solved

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

Posted on 2013-01-30
3
1,711 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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

778 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