Option Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jqtimbang
    New Member
    • Nov 2006
    • 14

    #1

    Option Button

    Hello, I'm using an option box here to find by d800no, company and pstnno fields but I'm getting 'run time error 424 object required'. What code is missing in my script below.

    Code:
    Dim Category As String
    Dim OptionNumber As Integer
    Dim SelItem As Integer
    Dim SearchStr As String
    
    
    Private Sub RunSearch()
    Select Case OptionNumber
        Case 0
        Category = "D800no"
        
        Case 1
        Category = "Pstnno"
        
        Case 2
        Category = "Company"
        
    End Select
    
    If OptionNumber = 1 Then
         Adodc1.RecordSource = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Text & "*'"
    Else
         Adodc1.RecordSource = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Text & "*'"
    
    End If
    Adodc1.Refresh
    End Sub
    
    
    Private Sub OPts_Click(Index As Integer)
    OptionNumber = Index
    End Sub
    
    Private Sub Cmd_Find1_Click()
    If Trim(txtSearchStr.Text) = "" Then Exit Sub
    RunSearch
    End Sub
    Last edited by Killer42; Mar 23 '07, 02:30 AM. Reason: Please use [CODE]...[/CODE] tags around your code.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Which line is producing the error?

    Comment

    • jqtimbang
      New Member
      • Nov 2006
      • 14

      #3
      Originally posted by Killer42
      Which line is producing the error?

      Else
      Adodc1.RecordSo urce = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Te xt & "*'"

      Comment

      • jqtimbang
        New Member
        • Nov 2006
        • 14

        #4
        Here's the format of my form frmFind:

        Search : [textbox]

        o by D800no o by Company o by Pstnno


        &Find Find&Next

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by jqtimbang
          Else
          Adodc1.RecordSo urce = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Te xt & "*'"
          Well, the syntax of the SELECT statement looks OK to me, though there could be some question about whether all table/field names are correct (including the one in txtSearchStr.Te xt) and whether any of your search fields are numeric (which might not agree with the Like operator). But all I can think of as a likely cause here is that Adodc1 is not set up properly. Can you double-check your connection settings?

          Unfortunately, database connections are an area where I'm rather weak.

          Comment

          Working...