Sub String Search using a Form

R

RAGS

I have an ACESS table containg Columns ITEM NO and its DESCRIPTION. I want to
design a FORM where if I enter a word or sub string of a word in the
Description field, I should get a report of all records satisfying the
criteria. Please help me. I am a beginner in ACCESS. Thank you.
 
A

Allen Browne

Create the report laid out the way you want the results.

Add a text box to a form, and set its Name to (say) txtDescription.
Add a command button, with these properties:
Name cmdPrint
On Click [Event Procedure]

Click the Build button (...) beside the On Click property.
Access opens the code window.
Set up the code so it looks like this:

Private Sub cmdPrint_Click()
Dim strWhere As String
strWhere = "[Description] Like *""" & Me.txtDescription & "*"""
DoCmd.OpenReport "Report1", acViewPreview, , strWhere
End Sub

Some other examples of opening a report filtered to a key value:
http://allenbrowne.com/casu-15.html
or to a date range:
http://allenbrowne.com/casu-08.html
 
Top