This should do what you want.
1.Look at the subform queries and see the two calculated fields I added
strTask and strStat.
Modify those fields in the CSTR to match whatever fields you are actually filtering for the task and station.
If the fields you are filtering are not numeric then you do not have to convert to string in the query, but then reference the correct field names in the code. Originally, I thought you were using the station_ID and task_ID, but I do not think those are the fields. So you can probably get rid of these two calculated fields in the subform and use the correct names in the code.
2. Here is the basic code. It should always be in the Parent form and not Subforms.
Code:
Dim FAYtRight As New FindAsYouTypeForm
Private Sub Form_Load()
'Rollback means if the text is not found it rollsback one character
FAYTLeft.Initialize Me.frmTaskcont2_sub1.Form, Me.txtFilter, ffrm_FromBeginning, False, False
FAYTLeft.FilterType = GetDirection
SetSearchFields FAYTLeft
FAYtRight.Initialize Me.frmTaskcont2_sub2.Form, Me.txtFilter, ffrm_FromBeginning, False, False
FAYtRight.FilterType = GetDirection
SetSearchFields FAYtRight
End Sub
'Needed when you change the search field or type of search
Public Sub SetSearchFields(FAYT As FindAsYouTypeForm)
FAYT.RemoveSearchField "strTask"
FAYT.RemoveSearchField "strStat"
If Me.frameField = 1 Then
FAYT.AddSearchField "strTask"
FAYT.AddSearchField "strStat"
End If
End Sub
Public Function GetDirection() As FormFilterType
If Me.frameType = 1 Then
GetDirection = ffrm_FromBeginning
Else
GetDirection = ffrm_Anywhereinstring
End If
End Function
3. I had to modify the Class. In the class there is functionality to "rollback". If you type a value and add a character if the filter no longer returns results it rolls back one character.
Example
2
21
213 'Nothing found so rolls textbox and filter back to
21
This will not work if you are filtering two forms at the same time because one might find nothing and the other something. I added a parameter to the class to turn off the rollback if you want.
View attachment 113638View attachment 113639
In my world you filter by task or station, but makes no sense to search both simultaneously.
No they clearly do not. Maybe the same fields but not the same number of records. one has around 760 the other around 1100. Therefore the class had to be modded not to rollback.
I get that but searching both Taks and Stations at the same time makes NO sense. They do not have the same type of information.
But it does and you already coded it.
View attachment 113640
That makes sense, but the example you provided did not. It showed stations IDs and TaskIDs and that just would not be a good fit. If tasks are something more than an ID that makes more sense.
If you do want to search fields at the same time then modify the code in SetSearchFields. My issue was an Option Group where you were forced to pick a single option made more sense.
To see why the class would not work well originally, set the Rollback to True in the initialize. This works great for a single subform/form but would fail in your case where one subform returns no results.