When a Microsoft Access form with a linked subform is opened, it automatically defaults to the first record in the subform. You may want to highlight another record as the current one.
Similarly, when the master record is updated (without moving to another record), the subform resets itself to the first record when you prefer to keep pointing to the same subform record.
If you have the ID of the subform row that should be the current one, use it to move to that record with the subform's RecordsetClone object and bookmark property.
Add the ResyncSubformRecord procedure to your form's module and call it like this to resync your subform record to the one you want:
Call ResyncSubformRecord(Me, "subformName", "MyField", lngValue)
Sub ResyncSubformRecord(frm As Form, strSubformName As String, strFieldName As String, lngID as Long) ' Comments: Update a subform to make a specific record the current one ' Params : frm Form object with the subform (usually Me if invoked from the parent form) ' 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 ' Create a recordset to the subform records Set rst = frm.Controls(strSubformName).Form.RecordsetClone ' Find the first record with the specified value. ' This is designed for a numeric value. If it's a string, add quotes around it rst.FindFirst "[" & strFieldName & "] = " & lngID If Not rst.NoMatch Then ' If the value is found, resync the subform record by using the recordset's Bookmark property frm.Controls(strSubformName).Form.Bookmark = rst.Bookmark End If rst.Close End Sub
Note that you need to do this AFTER you make changes to the subform that could cause it to reset the current record. For instance, these commands would reset the current record:
Strategic Overview
Microsoft Access within an Organization's Database Strategy
How many simultaneous Microsoft Access users?
Blaming Microsoft Access instead of the Developer
Microsoft Access Version Feature Differences
Microsoft Access Versions, Service Packs and Updates
Microsoft Office 365 Access Update Version Releases
Top 14 Features Added with MS Access 2007
Taking Over Legacy MS Access Databases
Winner of Every Best Access Add-in Award
Set AutoNumber Starting Number Other than 1
Avoid Unnecessary or Duplicate Indexes
Copy Command Button and Keep Picture
Module VBA to Forms and Controls
Subform Reference to Control Rather than Field
Suppress Page Headers and Footers on the First Page of Your Report
Annual Monthly Crosstab Columns
Add Buttons to the Quick Access Toolbar
Collapse the Office Ribbon for more space
Avoid Exits in the Body of a Procedure
Send Emails with DoCmd.SendObject
Error Handling and Debugging Techniques
Error Number and Description Reference
Remote Desktop Connection Setup
Terminal Services and RemoteApp Deployment
Missing Package & Deployment Wizard
Remove 'Save to SharePoint Site' Prompt from an Access Database
Class Not Registered Run-time Error -2147221164
Microsoft Access to SQL Server Upsizing Center
When and How to Upsize Access to SQL Server
SQL Server Express Versions and Downloads
Deploying MS Access Linked to SQL Azure
SQL Server Azure Usage and DTU Limits