By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,632 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,632 IT Pros & Developers. It's quick & easy.

Option Button

P: 14
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.

Expand|Select|Wrap|Line Numbers
  1. Dim Category As String
  2. Dim OptionNumber As Integer
  3. Dim SelItem As Integer
  4. Dim SearchStr As String
  5.  
  6.  
  7. Private Sub RunSearch()
  8. Select Case OptionNumber
  9.     Case 0
  10.     Category = "D800no"
  11.  
  12.     Case 1
  13.     Category = "Pstnno"
  14.  
  15.     Case 2
  16.     Category = "Company"
  17.  
  18. End Select
  19.  
  20. If OptionNumber = 1 Then
  21.      Adodc1.RecordSource = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Text & "*'"
  22. Else
  23.      Adodc1.RecordSource = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Text & "*'"
  24.  
  25. End If
  26. Adodc1.Refresh
  27. End Sub
  28.  
  29.  
  30. Private Sub OPts_Click(Index As Integer)
  31. OptionNumber = Index
  32. End Sub
  33.  
  34. Private Sub Cmd_Find1_Click()
  35. If Trim(txtSearchStr.Text) = "" Then Exit Sub
  36. RunSearch
  37. End Sub
Mar 23 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
Which line is producing the error?
Mar 23 '07 #2

P: 14
Which line is producing the error?

Else
Adodc1.RecordSource = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Text & "*'"
Mar 23 '07 #3

P: 14
Here's the format of my form frmFind:

Search : [textbox]

o by D800no o by Company o by Pstnno


&Find Find&Next
Mar 23 '07 #4

Expert 5K+
P: 8,434
Else
Adodc1.RecordSource = "Select D800no, Company, Pstnno From dtfs_2005 Where " & Category & " like '*" & txtSearchStr.Text & "*'"
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.Text) 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.
Mar 23 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.