PDA

View Full Version : Find button to search subform



mwork
05-13-2007, 05:20 PM
Hey All,
I am trying to make a button in the main form that will search the subform. Here is what I have:
Private Sub Find_Click()
Dim strFindRecord As String

strFindRecord = InputBox("Enter a name to find", "Enter Name")
DoCmd.GoToControl ("ctlPart_Number")
DoCmd.FindRecord strFindRecord

End Sub

It works if ctlPart_Number is in the main form, but not if it is in the subform. How do I get it to work?

OBP
05-14-2007, 01:59 AM
mwork, you need to refer to the Subform in the code.
Something like
me.Subformname.ctlPart_Number.setfocus
where Subformname is the actual name of your subform.
I am not sure that the
DoCmd.FindRecord strFindRecord
will work with that or not, you may have to use a Recodset.