This will simplify the if-then-else
Also, See the red. strSearch has never been given a value.
Code:
Private Sub cmdSearch_Click()
Dim lRecCount As Long 'holds # of found
Dim strSearch As String 'this looks up the text written for search
Dim strFind As String 'this looks up in SQL for text searched
'check if a keyword has been entered or not then vbYellow textbox if not + msgbox
If IsNull(Me.txtSearch) Or Me.txtSearch = "" Then
MsgBox "Please type in your search keyword.", vbInformation, "Keyword Needed!"
Me.txtSearch.BackColor = vbYellow
Me.txtSearch.SetFocus
exit sub
End if
'if record found then highlight RecFound box + filters
If strSearch = Me.txtSearch.Value Then
strFind = "SELECT * FROM tblQuestion WHERE ((Question Like ""*" & strSearch & "*"") OR (Possible1 Like ""*" & strSearch & "*"") OR (Possible2 Like ""*" & strSearch & "*"") OR (Possible3 Like ""*" & strSearch & "*"") OR (Possible4 Like ""*" & strSearch & "*""))"
Me.RecordSource = strFind
Me.txtSearch.SetFocus
Me.RecID.BackColor = vbGreen
Me.RecID.ForeColor = vbBlack
exit sub
End if
'if record not found then vbRed textbox + msgbox
If strFind = Me.txtSearch.Value = False Then
Me.txtSearch.BackColor = vbRed
DoCmd.CancelEvent
Me.txtSearch.SetFocus
MsgBox "Record not found!", vbExclamation, "Oh Nooooo!"
End If
End Sub