How can I search two fields from one table at one time?

I need to search a table called tblsubjects, for either by the name (field subjectlast) or case number (field casenumber) I want to use a text box on my form to enter the search criteria. After the criteria has been entered I would like to populate a sub form with the results. i would like the search to be a close match, it does not have to be and exact match. Any ideas how to get started in the right direction?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you dont need a sub form, you can use a continuous form.
on the form's header , put an unbound textbox (say you call it txtFilter) for the user to fill the search criteria, and a command button "Search"
now write this code in the Click event of the button:
if txtFilter<>"" then
     Me.Filter="SubjectLast Like '*" & txtFilter & "*'
End If

now, i didnt understand the other field's thing (CaseNumber), the same search term is for both at the same time or the user needs to choose wether to search for matching SubjectLast OR CaseNumbers?
NorieVBA ExpertCommented:
How will the field to be searched be determined?

If you used 2 textboxes you could use something like this to filter by or as criteria.
If IsNull(txtSubject) Then
      strFilter = "subjectlast Like '*'"
     strFilter = "subjectlast Like '*" & txtSubject.Value & "*'"
End If

strFilter = strFilter & " Or "

If IsNull(txtCaseNo) Then
      strFilter = strFilter & " casenumber Like '*'"
     strFilter = strFilter & " casenumber Like '*" & txtCaseNo.Value & "*'"
End If

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try this:
Code filters Folder names if either FolderFrom or FolderTo (a copy utility) contanis characters typed in Text1 box.
Subform control name is B.
The code is in the Command1_Click event on the main form.

Private Sub Command3_Click()
    B.Form.FilterOn = False
    B.Form.Filter = "FolderFrom Like '*' & text1 & '*' OR FolderTo Like '*' & text1 & '*'"
     B.Form.FilterOn = True
End Sub
Commad1=> Command3
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.