Form Search (1 Viewer)

cktcPeterson

Member
Local time
Today, 12:54
Joined
Mar 23, 2022
Messages
73
I would like to have a search box that if I type in a word it list out all courses that contain that word.
Example
Search: Miller
List of courses with the word miller.

My next step is to select the course to view the roster.

Any guidance would be great.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:54
Joined
Oct 29, 2018
Messages
21,474
Lots of ways to do this. Can you show us what you got so far?
 

cktcPeterson

Member
Local time
Today, 12:54
Joined
Mar 23, 2022
Messages
73
All I have is a form. Nothing started.

I know how to do it from a combo box and I select the course and it filters the names in a subform.

For this I want to type in the box and hit go, then filter the courses associated with it.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:54
Joined
Oct 29, 2018
Messages
21,474
All I have is a form. Nothing started.

I know how to do it from a combo box and I select the course and it filters the names in a subform.

For this I want to type in the box and hit go, then filter the courses associated with it.
Can you post the code you're using for your combobox. It would be basically the same with a textbox.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:54
Joined
May 21, 2018
Messages
8,529
I know how to do it from a combo box and I select the course and it filters the names in a subform.
For this I want to type in the box and hit go, then filter the courses associated with it.

To filter a form need to set the filter property and turn the filter on.
example
Me.filter = "CourseName like '*Miller*'"
me.filteron = true

To turn the filter off set the filter to "" and/or set the FilterOn to false.

if you want to filter the subform need to apply the filter to the subform
Me.SubformName.Form.Filter

Code:
Private Sub cmdFilter_Click()
  If cmdFilter.Caption = "Filter" Then
    
     If (txtFilter & "") <> "" Then
       cmdFilter.Caption = "Un Filter"
       With Me.subFrmProducts.Form
         .Filter = "ProductName like '*" & txtFilter & "*'"
         .FilterOn = True
        End With
     End If
  Else
     With Me.subFrmProducts.Form
       .Filter = ""
       .FilterOn = False
      End With
     cmdFilter.Caption = "Filter"
  End If
 
End Sub
 

Attachments

  • SearchCourse.accdb
    1.1 MB · Views: 87

Gasman

Enthusiastic Amateur
Local time
Today, 21:54
Joined
Sep 21, 2011
Messages
14,310
All I have is a form. Nothing started.

I know how to do it from a combo box and I select the course and it filters the names in a subform.

For this I want to type in the box and hit go, then filter the courses associated with it.
So you just compare against the textbox instead of a combo?
 

LarryE

Active member
Local time
Today, 13:54
Joined
Aug 18, 2021
Messages
592
All I have is a form. Nothing started.

I know how to do it from a combo box and I select the course and it filters the names in a subform.

For this I want to type in the box and hit go, then filter the courses associated with it.
If you know how to do this with a combo box then use one and just set its Limit To List property to 'No' then filter the form using the After Update Event. That way you can either type in the filter criteria OR select it from a drop-down combo box. It works the same way.
 

bastanu

AWF VIP
Local time
Today, 13:54
Joined
Apr 13, 2010
Messages
1,402
I think the OP wants a version of cascading combos but with the first one replaced by a textbox. Should be a very easy setup, add the new filtering textbox (txtFilterByWord) to your existing form where you already have the working combo, add a Me.cboSearchCourse.Requery line in the Enter or GotFocus event of the combo (I used the name cboSearchCourse) and set the combo's row source (in design view of the form) to use the textbox:

SELECT CourseID, CourseName From tblCourse WHERE Instr(CourseName, Forms!frmYourForm!txtFilterByWord)>0

Cheers,
 

cktcPeterson

Member
Local time
Today, 12:54
Joined
Mar 23, 2022
Messages
73
I was able to do the search and filter how I want.
I have a list box. When I double click on the course I want the subform display the students enrolled.

I have a subform on my main form.

Thanks for everyones guidance.
 

cktcPeterson

Member
Local time
Today, 12:54
Joined
Mar 23, 2022
Messages
73
My subform is
BSA _Invoice_Roster_Subform

Both have a have course ID in the query.

If that helps.
 

jdraw

Super Moderator
Staff member
Local time
Today, 16:54
Joined
Jan 23, 2006
Messages
15,379
Readers are asking to see some of the code you have.
Copy the relevant code (or sections of code) and paste directly in the forum with some description of what it is.
It may also help if you provide a sample or description of exactly what you are trying to accomplish in simple, plain English.
 

cktcPeterson

Member
Local time
Today, 12:54
Joined
Mar 23, 2022
Messages
73
I used this tutorial
Create a Search Button on your Form in Microsoft Access. Find Button. Filter, FilterOn Properties - Bing video

When I search for a course it filters in a list box. (This works)
I want to double click on the course I want and in a subform it list all the students registered for that course.


1690413241228.png
 

GaP42

Active member
Local time
Tomorrow, 06:54
Joined
Apr 27, 2020
Messages
338
Is your subform linked to the parent form? What links the parent to the subform? - CourseID?
eg
1690423012670.png
 

Users who are viewing this thread

Top Bottom