Sub String Search using a Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top