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

Search Textbox

P: 2
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(txtsearchstring) = 0 Or IsNull(txtsearchstring) = True Then
MsgBox "You must enter a search string."

Else
LSearchString = textSearchString

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

'Clear search string
txtsearchstring = ""

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

End Sub
Mar 20 '08 #1
Share this Question
Share on Google+
1 Reply


P: 2
Disregard this question...after 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.
Mar 20 '08 #2

Post your reply

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