Hi all, I have been working on a database with search function, been looking everywhere and came up with the below code:
Code:
Private Sub searchbutton_Click()
Dim strsearch As String
Dim strText As String
strText = Me.[txtsearch].Value
If searchoption = 1 Then
strsearch = "SELECT * from [customer] where ([acc#] like ""*" & strText & "*"")"
ElseIf searchoption = 2 Then
strsearch = "SELECT * from [customer] where ([customername] like ""*" & strText & "*"")"
Else
strsearch = "SELECT * from [customer] where ([inv] like ""*" & strText & "*"")"
End If
Me.RecordSource = strsearch
End Sub
It works great, except when someone didn't type in the text box, it will return an error message with debug option due to null value - I tried the code On error goto 0 but it didn't work (probably because I do not know how), is there anyway to not show the error message? I just want it to do nothing when the value is null.
Thanks!!