Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / January 2007

Tip: Looking for answers? Try searching our database.

Resyncing a subform record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kurt - 31 Jan 2007 18:23 GMT
The following code comes from FMS as a Tip.

In order to make this code work, does this code get placed in the subform or
main form?

On what event of what form (Main or subform) should this procedure be
called?
=======================================================================

Resyncing a subform record
Provided by: Luke Chung, FMS President
When the master record is updated, the subform resets itself to the first
record. It would be 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
Douglas J. Steele - 31 Jan 2007 19:10 GMT
It would go on the Parent form.

What event depends on when you want it to fire. As the tip suggests, you
need it when the master record is updated, so calling that routine from the
parent form's AfterUpdate event would be a good place to start.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> The following code comes from FMS as a Tip.
>
[quoted text clipped - 41 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.