OpenForm and Navigate to Subform Record?

C

croy

I have a form that shows selected fields from a parent/child
table pair.

I have set up a dbl-click field in the form to open my main
data-entry form/subform to the appropriate main-form record.

Now I'd like the focus to move to the appropriate subform
record when the main form opens, but I'm lost as to how to
do this.
 
Joined
Feb 9, 2012
Messages
25
Reaction score
0
Something like this should work:

Code:
        With Me!SUBNAME.Form.RecordsetClone
            .FindFirst "[FIELDNAME] = " & RECORDNO
            If Not .NoMatch Then
                Me!SUBNAME.Form.Bookmark = .Bookmark
            End If
        End With
           Me!SUBNAME.SetFocus
           Me!SUBNAME.Form!FIELDNAME.SetFocus

NB: Obviously you need to replace the SUBNAME with the actual subform name and FIELDNAME with the actual field name on the sub. The RECORDNO will be the record you're navigating to and this maybe a control or a public variable but you will need to make sure the right datatype for the field is used.
 
Top