Boolean searches? Possible?

JVermast

Registered User.
Local time
Today, 05:02
Joined
Jun 15, 2005
Messages
70
I have a search tool, but right now it is 100% case sensitive in the sense that if i search for "test" and my entry is "Test" it will not return any results.

is there any way to setup so I could say search for "Test" and it would find "test" properly? Or even to the extreme where I searched for "Tes*" and it came back with the "test" entry.

Thanks,
 
What comparison are you currently using?
 
I should clarify, just in case: Option Compare Database, Option Compare Binary, or Option Compare Text?
 
Code:
Private Sub cmdSubmit_Click()
    Dim strSearch As String
    

    If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
        MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
        Me![txtSearch].SetFocus
    Exit Sub
End If

        
    DoCmd.ShowAllRecords
    DoCmd.GoToControl ("strSetNum")
    DoCmd.FindRecord Me!txtSearch
        
    strSetNum.SetFocus
    strStudentRef = strSetNum.Text
    txtSearch.SetFocus
    strSearch = txtSearch.Text

    If strStudentRef = strSearch Then
        
        strSetNum.SetFocus
        txtSearch = ""
        
        Else
            MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
            , "Invalid Search Criterion!"
            txtSearch.SetFocus
    End If
End Sub
 
Last edited by a moderator:
Conside the output of the message boxes in this bit of test code:

Code:
Public Function AreEqual()
    
    Const x As String = "A"
    Const y As String = "a"
    
    If StrComp(x, y, vbBinaryCompare) Then
        MsgBox "vbBinaryCompare: A = a", vbInformation
    Else
        MsgBox "vbBinaryCompare: A <> a", vbInformation
    End If
    
    
    If StrComp(x, y, vbTextCompare) Then
        MsgBox "vbTextCompare: A = a", vbInformation
    Else
        MsgBox "vbTextCompare: A <> a", vbInformation
    End If
    
    If StrComp(x, y, vbDatabaseCompare) Then
        MsgBox " vbDatabaseCompare: A = a", vbInformation
    Else
        MsgBox " vbDatabaseCompare: A <> a", vbInformation
    End If
    
End Function
 
Meaning place that as the code on my text box and leave the code the same on the button?
 
Have you simply try setting the control so that it is not case sensitive and then set the set criteria as follows:

If strStudentRef like (strSearch & "*") Then
Your Code goes here 'Return the results
End If
 
Is there any way I could do a boolean though, say I'm searching for a project name. The name is "Josh's Awesome project" and I want to be able to put "Josh*" and get that project to come up.
 
Code:
 If strStudentRef Like (strSearch & "*") Then
 

Users who are viewing this thread

Back
Top Bottom