Good Morning,
I'm using an Access form to collect input from a user and then export search results to Excel. The problem is I allow a user to select from a drop box or use a wildcard to see more results. All is fine if no wildcard is used and I use only the "Else" condition below. Each statement below works separately so I believe the problem is with my If Then and / or the way I'm trying to strip the user entered * by replacing with a space.
All help is greatly appreciated.
Dim xSrch As String
Dim isWildcard As String
isWildcard = InStr("'*" & Me.txtFindResult & "*'", "*")
sSearch = Replace(Me.txtFindResult, "*", "")
If isWildcard > 0 Then
‘Wildcard
xSQL = "SELECT B.[Book] FROM tblBooks AS B " _
& "WHERE B.Books Like '%" & Me.txtFindResult & "%' ;"
Else
‘No Wildcard
xSQL = "SELECT B.[Book] FROM tblBooks AS B " _
& "WHERE B.Books Like '" & Me.txtFindResult & "' ;”
Thanks!