I need some help urgently.
How can I set focus on a particular record in a subform?
Thanks
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Subform (Access 97)
>>How can I set focus on a particular record in a subform?<<
I'm assuming my "a particular record", you mean a record with a known ID (that is, primary key). Here's a summary of how I do it:
Open a recordset by setting it equal to the recordsetclone of the subform.
Use the recordset's .FindFirst method to find the particular record you want.
Then set the subform's bookmark = the recordset's bookmark.
Well, it hard to give a definitive code sample, because I have to assume a whole lot. Let’s start by where the code is running. Let’s assume it is running from your mainform. Other assumptions are: the subform control name (and not necessarily the name of the form within the control) we will call subRecords; the Primary Key field in the table behind the subform will be RecordID (a numeric field); and you have identified the RecordID you want to find in a field named txtRecordID. Your code would be something like this:
Dim rs as DAO.recordset
set rs = Me.subRecords.form.recordsetclone rs.FindFirst "RecordID=" & txtRecordID If rs.NoMatch=False then Me.subRecords.form.bookmark = rs.bookmark end if
There is an elaboration on this question in this thread, which has been locked so we don’t have two sets of answers going forward.
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications