return all entries where name contains "LEN"

  • Thread starter Thread starter ali
  • Start date Start date
A

ali

I have a table: (Dummy Scenario)
-ID
-Name
-Join_Date
-Remark





-------------------------------------------------------------------------------------
I'd like to:

Retrieve all entries where the name contains "LEN" ,

so names such as "ALLEN", "LENNY", "LENUS" etc.. should be returned.

(In SQL, we write --> where the name LIKE "*LEN*", )






-------------------------------------------------------------------------------------
My question:

1) how can i do it in a form ?
2) Is that possible to return all results into a "DataGrid" in MS Access
form ? if so , how ?



Dear expert, thanks a lot !
 
The filter of a form is the same as a WHERE clause in SQL.

Therefore something like this:

Private Sub txtMatchName_AfterUpdate()
dim strWhere As String
If Not IsNull(Me.txtMatchName) Then
If Me.Dirty Then Me.Dirty = False 'Save first.
strWhere = "[MyNameField] Like ""*" & Me.txtMatchName & "*"""
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub

If the quotes don't make sense, see:
http://allenbrowne.com/casu-17.html

For a more comprehensive example, see:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
 
Back
Top