Change code from "=" to "Like"

mshelley1

Carbo
Local time
Today, 05:26
Joined
Feb 12, 2006
Messages
45
Is it possible to change the following code from "[Name]='" & Me![subject] to
"[Name Like" & Me![subject]


Private Sub subject_LostFocus()
On Error GoTo Err_Command1777_Click
If IsNull(DLookup("[subject]", "[Warrant Log]", "[Name]='" & Me![subject] & "'")) Then
Exit Sub
End If
 
If IsNull(DLookup("[subject]", "[Warrant Log]", "[Name] Like '*" & Me![subject] & "*'")) Then


But shouldn't it be:
If IsNull(DLookup("[Name]", "[Warrant Log]", "[subject] Like '*" & Me![subject] & "*'")) Then

?
 
Below is the complete code I am working with; it works fine as long as everything is exact (not case sensitive), I have been working for days trying to code it to be a little more forgiving because of variations in name spelling and middle name / initials, issues (sometimes excluded / sometimes not). Any and all help will be greatly appreciated.

Carbo



Private Sub subject_LostFocus()

If IsNull(DLookup("[Name]", "Warrant Log", "[Name]='" & Me![subject] & "'")) Then
Exit Sub
End If

Dim nicholas As String

nicholas = MsgBox("Possible wanted person entered in the Subject field. Would you like GDB to check?", vbYesNo, "Warrant Check")
If nicholas = vbYes Then


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Advisory_Warrant"

stLinkCriteria = "[Name]=" & "'" & Me![subject] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command1778_Click:
Exit Sub

Err_Command1778_Click:
MsgBox Err.Description
Resume Exit_Command1778_Click
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom