• Does any one know how to search for the Asterisk?

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Does any one know how to search for the Asterisk?

    Author
    Topic
    #356362

    According to the online help (search for help on Like Operator), you need to put square brackets around the asterisk, i.e. Like “[*]”.

    Viewing 1 reply thread
    Author
    Replies
    • #527271

      My solution may not be the most elegant, but it works

      1. In the table that contains the data create a new ‘yes/no’ field (called it something like ‘FLAG’)

      2. Create a new module

      3. Add the following Code to the module (replace the , and with the names of the table you wish to search and the field you wish to search and use as the flag.

      4. Run this routine. VIOLA, all the fields that have an * at the end of them are CHECKED TRUE in the flag field!

      Sub SearchAst()
      Dim rstSearchTable As Recordset
      Dim strFieldSearch As String
      Dim strFieldFlag As String

      Set rstSearchTable = CurrentDb.OpenRecordset(“”, dbopentable)
      strFieldSearch = “”
      strFieldFlag = “”

      With rstSearchTable
      Do While Not .EOF
      If Right(.Fields(strFieldSearch), 1) = “*” Then
      .edit
      .Fields(strFieldFlag) = True
      .Update
      End If
      .MoveNext
      Loop
      End With
      End Sub

    • #527288

      Here’s a routine you could use to clean up those offending values:

      Public Function ExtractNumFromStr(ByVal strIn As String, _
                                  Optional intStartPos As Integer) As Variant
        'Created 2/16/2000 by Charlotte Foust
        On Error GoTo ExtractNum_err
        Dim varNum As Variant
        Dim strNum As String
        Dim strTemp As String
        Dim intLoop As Integer
      
        ' Get the number portion of the string
        
        'if they didn't pass in a start position
        'start at position 1
        If intStartPos = 0 Then
          intStartPos = 1
        End If ' intStartPos = 0 
        
        'grab the portion of the string to use
        strTemp = Right(strIn, 1 + Len(strIn) - intStartPos)
      
        'if the string is all numeric
        'return the whole string
        If IsNumeric(strTemp) Then
          strNum = strTemp
      
        'otherwise, extract the numbers
        'from the string
        Else 'IsNumeric(strTemp)
      
          'step through the string and test
          'each character, only returning the numbers
          For intLoop = intStartPos To Len(strIn)
      
            If IsNumeric(Mid(strIn, intLoop, 1)) Then
      
              strNum = strNum & Mid(strIn, intLoop, 1)
            End If 'IsNumeric(Mid(strIn, intLoop, 1))
          Next intLoop '  = intStartPos To Len(strIn)
      
          'if no numbers were found, return zero
          If Len(strNum) = 0 Then
      
            strNum = "0"
          End If 'Len(strNum) = 0 
        End If 'IsNumeric(strTemp)
      
        varNum = clng(strNum)
      ExtractNum_exit:
        On Error Resume Next
        ExtractNumFromStr = varNum
        Exit Function
      ExtractNum_err:
        Resume Next
      End Function 'ExtractNumFromStr(ByVal strIn As String, _
                                  Optional intStartPos As Integer) As Variant
    Viewing 1 reply thread
    Reply To: Does any one know how to search for the Asterisk?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: