Quick Find: Search for:
Free Resources
from FMS
 

Demos

Email Newsletter

Technical Papers

Tips and Techniques

Links

Book Recommendations

View all FMS products for Microsoft AccessMicrosoft Access Resource Center

 

 

"Thank you! Thank you!
I just finished reading this
document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.
" 
- Darren D.
 
  

 

Resyncing a Subform Record in Microsoft Access

Provided by: Luke Chung, FMS President

In a Microsoft Access form with a linked subform, when the master record is updated, the subform resets itself to the first record.

It is preferable to keep the record pointer at the same subform record. The solution is very simple. Get the ID identifying the row that should be the current one. Use this ID value to search on the RecordsetClone and use the bookmark property to resync your subform record.

Sub ResyncSubformRecord(strSubformName As String, _
                        strFieldName As String, _
                        lngID as Long)
  ' Comments: Update a subform to make a specific record the current one
  ' In      : strSubformName - Name of subform with data to resync
  '           strFieldName - Field to specify the search criteria
  '           lngID - ID value in the field to find (usually
  '           the primary key value) 

  Dim rst As DAO.Recordset

  Set rst = Me(strSubformName).RecordsetClone
    rst.FindFirst "[" & strFieldName & "] = " & lngID
    If Not rst.NoMatch Then
      Me(strSubformName).Bookmark = rst.Bookmark
    End If
  rst.Close
End Sub

 

Return to the tips page

Questions  l   Web questions: Webmaster   l   Copyright © 2008 FMS, Inc.

Celebrating 21 Years of Software Excellence