jeran042
Registered User.
- Local time
- Today, 13:59
- Joined
- Jun 26, 2017
- Messages
- 127
I have a continuous form that is a search form. A user can input any criteria (text before this question) and the record set of the form would be updated with anything LIKE what was typed into the search box. This all works fine.
What I am now trying to accomplish is to add Integers to the search. For example, if the user types "15.46" into the search box, I want to look through the record set for that exact string.
Here is what I currently have for code:
I currently get a Runtime error 13, which I would expect, as this was originally only meant for text, any help updating the "strsearch" would be appreciated,
What I am now trying to accomplish is to add Integers to the search. For example, if the user types "15.46" into the search box, I want to look through the record set for that exact string.
Here is what I currently have for code:
Code:
Private Sub cmdSEARCH_Click()
Dim strsearch As String
Dim strText As String
'Error handling
On Error GoTo Error_Handler
'Pull value from text box
strText = Trim(Me.txtSearch.value)
'SQL Statement
strsearch = "Select * from qryLedger_Detail_SEARCH WHERE DESCRIPTION like ""*" _
& strText & "*"" or VOUCHER like ""*" _
& strText & "*"" or POLICY like ""*" _
& strText & "*"" or ACCOUNT_NUMBER like ""*" _
& strText & "*"" or NOTES like ""*" _
& strText & "*"" or DEBIT = " _ 'newly added
& strText * " OR CREDIT =" _ 'newly added
& strText * " ORDER BY [MO_DAY] DESC"
'Update the recordsource with SQL statement
Me.RecordSource = strsearch
'Reload form with blank textbox
Me.txtSearch = Null
'Set focus of textbox after search
txtSearch.SetFocus
'Error handling
Error_Handler_Exit:
Exit Sub
Error_Handler:
Select Case Err.NUMBER
Case 94
Err.Clear
Resume Error_Handler_Exit
Case Else
MsgBox "Error No. " & Err.NUMBER & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error"
Err.Clear
Resume Error_Handler_Exit
End Select
End Sub
I currently get a Runtime error 13, which I would expect, as this was originally only meant for text, any help updating the "strsearch" would be appreciated,