Findfirst on the Subform

  • Thread starter Thread starter Bradley C. Hammerstrom
  • Start date Start date
B

Bradley C. Hammerstrom

Access2000

********************************
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
With Me.RecordsetClone
.FindFirst "PhotoID = " & Me.OpenArgs
If Not .NoMatch Then Me.Bookmark = .Bookmark
End With
End If

End Sub
******************************
The problem is that PhotoID is on the subform, not the main form. The main
form opens showing all records, then the user can pick from a couple of
combos to narrow the subform, but I want the form to open when called from
the other form (which sets the OpenArgs to PhotoID) and go to that PhotoID
on the subform (that shows all records by default).

How do I refer to the subform in the .FindFirst statement?

Brad H.
 
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
With Me.SubformControl.Form.RecordsetClone
.FindFirst "PhotoID = " & Me.OpenArgs
If Not .NoMatch Then Me.SubformControl.FormBookmark = .Bookmark
End With
End If
End Sub

The SubformControl is the name of the control on the main form that holds the subform, not
the name of the subform itself. To get this name, open the main form in design mode and
open the Properties sheet. Click on the subform ONE time and the Properties sheet should
show the name of the subform control. If you click on the subform more than once, you will
be in the subform and the Properties sheet will show the name of the subform, not the
control holding it.
 
Beautiful! Thanks Wayne!
Brad H.


Wayne Morgan said:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
With Me.SubformControl.Form.RecordsetClone
.FindFirst "PhotoID = " & Me.OpenArgs
If Not .NoMatch Then Me.SubformControl.FormBookmark = ..Bookmark
End With
End If
End Sub

The SubformControl is the name of the control on the main form that holds the subform, not
the name of the subform itself. To get this name, open the main form in design mode and
open the Properties sheet. Click on the subform ONE time and the Properties sheet should
show the name of the subform control. If you click on the subform more than once, you will
be in the subform and the Properties sheet will show the name of the subform, not the
control holding it.
 
Back
Top