Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Posts
    22

    Question Unanswered: Use InStr to Strip * Entered by User

    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!

  2. #2
    Join Date
    Dec 2010
    Posts
    22
    Problem solved. The wildcard section should use xSrch, not the original txtFindResult. Should have looked closer before I posted.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •