Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

862 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

23 Experts available now in Live!

Get 1:1 Help Now