yhchen
Registered User.
- Local time
- Today, 03:56
- Joined
- Jul 6, 2008
- Messages
- 63
Text search in a form
Hi guys
I know very little about VBA codes but managed to find a well-written VBA code which I can use for my form - which you can enter text and search to display the result in the subform. It works perfectly well...
However, I would like to create the 2nd text box to enable the search for "Forename1" and I made the following amendments (which the previous code still exists):
(amended part shown as red)
after the amendments, it works ok but it gives me an error message saying: Run-time error '424' object required.
Please can anyone help?
Many thanks in advance for any help can be offered.



Hi guys
I know very little about VBA codes but managed to find a well-written VBA code which I can use for my form - which you can enter text and search to display the result in the subform. It works perfectly well...
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 = txtSearchString
'Filter results based on search string
LSQL = "select * from A2AtivatedMembers"
LSQL = LSQL & " where Surname LIKE '*" & LSearchString & "*'"
Form_Data.RecordSource = LSQL
lblTitle.Caption = "Customer Details: Filtered by '" & LSearchString & "'"
'Clear search string
txtSearchString = ""
MsgBox "All Record containing " & LSearchString & "."
However, I would like to create the 2nd text box to enable the search for "Forename1" and I made the following amendments (which the previous code still exists):
(amended part shown as red)
Private Sub cmdSearch2_Click()
Dim LSQL As String
Dim LSearchString As String
If Len(txtSearchString2) = 0 Or IsNull(txtSearchString2) = True Then
MsgBox "You must enter a search string."
Else
LSearchString = txtSearchString2
'Filter results based on search string
LSQL = "select * from A2AtivatedMembers"
LSQL = LSQL & " where Forename1 LIKE '*" & LSearchString & "*'"
Form_Data.RecordSource = LSQL
lblTitle.Caption = "Customer Details: Filtered by '" & LSearchString & "'"
'Clear search string
txtSearchString2 = ""
MsgBox "All Record containing " & LSearchString & "."
End If
End Sub
after the amendments, it works ok but it gives me an error message saying: Run-time error '424' object required.
Please can anyone help?
Many thanks in advance for any help can be offered.



Last edited: