search in subform of a form

ranen

pinoy 'to
Local time
Today, 15:20
Joined
Jun 14, 2005
Messages
29
i do have a form with a subform when i am searching record thru the subform i cannot find a record. how will i do that when i click search and the focus is in subform?thanx in advance
 
First you have to create a field, example txtSearch and the field which you want to search in the subform let's say CompanyName. Then, goto the txtsearch field propriety, find something like update event on change and click on it.

Put the code below and modified field names and subform names to match your form.


Private Sub txtSearch_Change()
On Error GoTo Err_TrapError

Dim temp As String
temp = "*" & txtSearch.Text & "*"

If Not (txtSearch.Text = "") Then
Me.subfrmCompanySearch.Form.Filter = "CompanyName like '" & temp & "'"
Me.subfrmCompanySearch.Form.FilterOn = True
Else: Me.subfrmCompanySearch.Form.FilterOn = False
End If

End Sub

Hope this code will help.

Le888
 

Users who are viewing this thread

Back
Top Bottom