Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Jan 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subform (Access 97)

    I need some help urgently.
    How can I set focus on a particular record in a subform?

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: 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.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Lounger
    Join Date
    Jan 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform (Access 97)

    Mark, could you please give me a sample code.

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Subform (Access 97)

    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
    <pre>set rs = Me.subRecords.form.recordsetclone
    rs.FindFirst "RecordID=" & txtRecordID
    If rs.NoMatch=False then
    Me.subRecords.form.bookmark = rs.bookmark
    end if </pre>

    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Subform (Access 97)

    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.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •