search field and subforms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am looking to search for a record (using a combo box as a search field) based on the value of a field in a subform. What I have written results in an error saying that it can't find the field name in the current record. Even though in the code I'm trying to direct the search to the subform, perhaps I'm not doing it right. The subform is called [tblApplicants subform1] and the field in the subform is [Surname] so I thought that I could identify the field as [tblapplicants subform1].surname in the code below

Private Sub Search_AfterUpdate(
If IsNull([Search]) = False The
DoCmd.GoToControl "tblapplicants subform1].surname
DoCmd.FindRecord [Search], A_STAR
DoCmd.GoToControl "Search
End I
Me.Search.SetFocu
End Su

Which it doesn't like, could anyone please advise me on how to get through this one. Much appreciated.
 
Try setting focus to the subform itself, and then to the text box within it:
Me.[tblapplicatns subform1].SetFocus
Me.[tblapplicatns subform1].Form!Surname.SetFocus
DoCmd.FindRecord ...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Matt said:
I am looking to search for a record (using a combo box as a search field)
based on the value of a field in a subform. What I have written results in
an error saying that it can't find the field name in the current record.
Even though in the code I'm trying to direct the search to the subform,
perhaps I'm not doing it right. The subform is called [tblApplicants
subform1] and the field in the subform is [Surname] so I thought that I
could identify the field as [tblapplicants subform1].surname in the code
below:
Private Sub Search_AfterUpdate()
If IsNull([Search]) = False Then
DoCmd.GoToControl "tblapplicants subform1].surname"
DoCmd.FindRecord [Search], A_START
DoCmd.GoToControl "Search"
End If
Me.Search.SetFocus
End Sub

Which it doesn't like, could anyone please advise me on how to get through
this one. Much appreciated.
 
Back
Top