Need help w/Pseudo-Splitform with search box
I have a parent form that emulates split view (fmTasks, source: tbTasks). In the footer of fmTasks is a subform that is in datasheet view (sbfm_Tasks, source quTasks). Clicking on a record in the subform (On Current event) loads the record in the parent form. All good.
I implemented a search/filter box in the header of the parent form that filters (via On Change event) the query that sbfm_Tasks is based off. This works fine, however, now records won't load in the parent form when I click on them from the subform. Clicking on a record in the subform moves the selection to the first record in the subform which forces the main form to load only that first record. The main form does load the clicked record for about a tenth of a second, but it quickly goes to the first record. Clicking the record navigation buttons in the subform results in the same thing. Can anyone help me out? I've been scouring the interwebs the last 2 days trying different methods of loading the record in the main form to no avail. :banghead:
The code for the On Current event of the subform is this:
The code for the On Change event of the filter box:
I have a parent form that emulates split view (fmTasks, source: tbTasks). In the footer of fmTasks is a subform that is in datasheet view (sbfm_Tasks, source quTasks). Clicking on a record in the subform (On Current event) loads the record in the parent form. All good.
I implemented a search/filter box in the header of the parent form that filters (via On Change event) the query that sbfm_Tasks is based off. This works fine, however, now records won't load in the parent form when I click on them from the subform. Clicking on a record in the subform moves the selection to the first record in the subform which forces the main form to load only that first record. The main form does load the clicked record for about a tenth of a second, but it quickly goes to the first record. Clicking the record navigation buttons in the subform results in the same thing. Can anyone help me out? I've been scouring the interwebs the last 2 days trying different methods of loading the record in the main form to no avail. :banghead:
The code for the On Current event of the subform is this:
Code:
Private Sub Form_Current()
If CurrentProject.AllForms("sbfm_Tasks").IsLoaded = True Then
Exit Sub
Else
Me.Parent.Recordset.FindFirst "Task_ID = " & Me.Task_ID
End If
End Sub
Code:
Private Sub txtFilter_Change()
Dim strFilterText As String
strFilterText = txtFilter.Text
txtHiddenFilter.Value = strFilterText
Me.sbfm_Tasks.Requery
'Tests for a trailing space and exits the sub routine at this point
'so as to preserve the trailing space, which would be lost if focus was shifted from Text Box txtFilter
If Len(Me.txtHiddenFilter) <> 0 And InStr(Len(txtHiddenFilter), txtHiddenFilter, " ", vbTextCompare) Then
'Set the focus on the first item in the list box
'Me.SearchResults = Me.SearchResults.ItemData(1)
'Me.SearchResults.SetFocus
'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of the List Box
'DoCmd.Requery
'Returns the cursor to the the end of the text in Text Box txtFilter,
'and restores trailing space lost when focus is shifted to the list box
Me.txtFilter = strFilterText
Me.txtFilter.SetFocus
Me.txtFilter.SelStart = Me.txtFilter.SelLength
Exit Sub
End If
'Set the focus on the first item in the list box
'Me.SearchResults = Me.SearchResults.ItemData(1)
'Me.SearchResults.SetFocus
'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of the List Box
'DoCmd.Requery
'Returns the cursor to the the end of the text in Text Box txtFilter
Me.txtFilter.SetFocus
If Not IsNull(Len(Me.txtFilter)) Then
Me.txtFilter.SelStart = Len(Me.txtFilter)
End If
End Sub
Attachments
Last edited: