Search Textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Polly
    New Member
    • Mar 2008
    • 2

    Search Textbox

    I am trying to create a search field in a master form which will filter the results in a subform. My problem is that everytime I try to run the code I get an error time message "run time 424: Object Required." It appears that the reference to the subform as a record source is not correct but I have not been able to find out how to fix the issue. Since I am new at VBA I would appreciate any tips on how to fix the problem. The following is the VBA code that I am trying to use:

    Private Sub cmdSearch_Click ()
    Dim LSQL As String
    Dim LSearchString As String

    If Len(txtsearchst ring) = 0 Or IsNull(txtsearc hstring) = True Then
    MsgBox "You must enter a search string."

    Else
    LSearchString = textSearchStrin g

    'Filter Resuts based on search string
    LSQL = "select * from AI_tbl"
    LSQL = LSQL & "where ActionItems LIKE '*" & LSearchString & "*'"
    Form_Item_sub.R ecordSource = LSQL
    lblTitle.Captio n = "Action Item Details: Filtered by '" & LSearchString & "'"

    'Clear search string
    txtsearchstring = ""

    MsgBox "Results have been filtered. All action items containing " & LSearchString & "."
    End If

    End Sub
  • Polly
    New Member
    • Mar 2008
    • 2

    #2
    Disregard this question...afte r I hit my head on the wall enough times I finally saw that the "Has module" form property was set to no. I reset it to yes and it is working great.

    Comment

    Working...