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 !

Signature
Allen Phailat Wongakanit
Allen Browne - 05 Mar 2008 07:38 GMT
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

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>I have a table: (Dummy Scenario)
> -ID
[quoted text clipped - 17 lines]
> 2) Is that possible to return all results into a "DataGrid" in MS Access
> form ? if so , how ?