• Subform (Access 97)

    Author
    Topic
    #368426

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

    Thanks

    Viewing 1 reply thread
    Author
    Replies
    • #577272

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

      • #577282

        Mark, could you please give me a sample code.

        • #577302

          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 
    • #577358

      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.

    Viewing 1 reply thread
    Reply To: Subform (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: