Solved

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

Posted on 2013-01-30
3
1,610 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks fyed
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now