K
Kurt
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
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