Findfirst on the Subform

  • Thread starter Bradley C. Hammerstrom
  • 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.
 
W

Wayne Morgan

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

Bradley C. Hammerstrom

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Open form, go to record on subform 2
Openargs Not Working 2
FindFirst trouble 1
Open and goto same ID on subform 11
Finding value in Form Load event 3
Adding Record to Table 1
Clone Code Complication 2
With error 7

Top