Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2008
    Posts
    1

    Unanswered: searching a form - runtime error

    I have created a form to search a sub_form, but with the code im useing im getter run-time error 424: Object required.. can someone let me know where im going wrong?


    Code:
    Private Sub Command5_Click()
     
        Dim LSQL  As String
        Dim LSearchString As String
        
        If Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
            MsgBox "You must enter a search string."
            
        Else
        
            LSearchString = txtSearchString
            
            'Filter results based on search string
            LSQL = "select * from [Employer Profile - Master Table]"
            LSQL = LSQL & " where [Business Name] LIKE '*" & LSearchString & "*'"
            
            [Form_Employer Profile - Master Form].RecordSource = LSQL
            
            lblTitle.Caption = "Customer Details:  Filtered by '" & LSearchString & "'"
            
            'Clear search string
            txtSearchString = ""
            
            MsgBox "Results have been filtered.  All Company Names containing " & LSearchString & "."
            
        End If
    End Sub

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What is this: txtSearchString??

    If it's a textbox on a form then you need to use a different notation, namely
    Me.txtSearchString.Value
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I'm gonna guess it is this line:
    Code:
     [Form_Employer Profile - Master Form].RecordSource = LSQL
    But I shouldn't be guessing - let us know which line throws the error!
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by georgev
    What is this: txtSearchString??

    If it's a textbox on a form then you need to use a different notation, namely
    Me.txtSearchString.Value
    It can work for a textbox. Not recommended of course
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    What does Command5 mean?

    It would sure help if we knew which line the code was stopping on......
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •