Filter using any characters

  • Thread starter Thread starter gmenon100 via AccessMonster.com
  • Start date Start date
G

gmenon100 via AccessMonster.com

Hi Friends,

I have an ADP database with backend SQL,

I have an unbound textbox and a command button and need to filter data on a
subform based on any character entered in the textbox.

For eg. when BL is typed and the command clicked, the subform should diplay
all rows where "BL" exits in any part of the field. so in this case it
should filter BLACK or ABLE etc.

I tried to search thru this database, but could not find a solution.

Any help is appreciated!!

Gmenon
 
There's no way to do this through standard Access properties, so you'll have
to adjust the subform's filter on your own. In the Click event for the
command button (or maybe even the Change event for the text box?), you would
put:

With MyForm!MySubFormControl.Form
.Filter = "MyField LIKE '%" & MyForm!MyTextBox.Value & "%'"
.FilterOn = True
End With

I think that should do it, but if you have any problems, post back and we'll
go from there.



Rob
 
Appreciate your response. Will try this and revert.

Thanks again.
Gmenon

Robert said:
There's no way to do this through standard Access properties, so you'll have
to adjust the subform's filter on your own. In the Click event for the
command button (or maybe even the Change event for the text box?), you would
put:

With MyForm!MySubFormControl.Form
.Filter = "MyField LIKE '%" & MyForm!MyTextBox.Value & "%'"
.FilterOn = True
End With

I think that should do it, but if you have any problems, post back and we'll
go from there.

Rob
Hi Friends,
[quoted text clipped - 14 lines]
 
Hi Rob,

Thanks! Thanks It worked.

I used your suggestion as below:

Private Sub Search_Click()
Dim strWhere As String
Dim strError As String

strWhere = "1=1"
' If Title
If Nz(Me.InvoiceNo) <> "" Then
' Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "BrowseShipments.Productname Like '%"
& Me.InvoiceNo.Value & "%'"
End If

If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Browse All Issues", acFormDS, , strWhere, acFormEdit,
acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Shipments.Form.Filter = strWhere
Me.Browse_All_Shipments.Form.FilterOn = True
End If
End Sub



Appreciate your response. Will try this and revert.

Thanks again.
Gmenon
There's no way to do this through standard Access properties, so you'll have
to adjust the subform's filter on your own. In the Click event for the
[quoted text clipped - 16 lines]
 
Back
Top