Search Textbox on Main restricts data entry on Subform

lydonw

Registered User.
Local time
Today, 11:02
Joined
Aug 14, 2012
Messages
49
I have a form whose Record Source is a query (lists consumer information), with two subforms. One subform is for data entry and has a table for a record source (lists of authorizations, with foreign key ConsumerID). The other subform is used to view and edit the same data entered through the other subfrom, but it's record source is a query.

All of that works just fine. The problem is, I have a textbox that I using to search through the records on the main form with an OnChange event of
Code:
Private Sub txSearch_Change()
    Dim strFilter As String
    On Error GoTo ErrHandler
    If Me.txSearch.Text <> "" Then
        strFilter = "[ConsumerLast]Like '*" & Me.txSearch.Text & "*' Or [ConsumerFirst]Like '*" & Me.txSearch.Text & "*'"
        Me.Filter = strFilter
        Me.FilterOn = True
    Else
        Me.Filter = ""
        Me.FilterOn = False
    End If
    With Me.txSearch
        .SetFocus
        .SelStart = Len(Me.txSearch.Text)
    End With
    Exit Sub
ErrHandler:
    Dim Response
    Response = MsgBox("No consumers returned in search", vbOKOnly, "No Results")
    txSearch = ""
    DoCmd.Close
    DoCmd.OpenForm "Consumers"
End Sub

The search function works fine, BUT when I use it the data entry subform populates with one record from the subform record source, rather than being a blank data entry form. I have no idea why.

Does anyone know why this is happening, and how I can fix it?
 
I spent some more time searching for cases where other people have had this issue and have come up with bunk. I find many issues with data entry subforms, and many issues with creating an unbound textbox search, but nothing that combines the two problems.

To be clear: Unbound search textbox and data entry subform work fine in isolation, but when I use the search textbox the subform displays a record, rather than being data entry.
 

Users who are viewing this thread

Back
Top Bottom