Option Compare Database
'------------------------------------------------------------
' Search
'
'------------------------------------------------------------
Function Search()
On Error GoTo Search_Err
With CodeContextObject
If (Eval("[Form]![SearchBox] Is Null Or [Form]![SearchBox]=""""")) Then
' Clear Filter when search box empty
DoCmd.ApplyFilter "", """"""
DoCmd.GoToControl "SearchBox"
DoCmd.SetProperty "SearchClear", acPropertyVisible, "0"
DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
End If
If (Eval("[CurrentProject].[IsTrusted] And ([Form]![SearchBox] Is Null Or [Form]![SearchBox]="""")")) Then
.SearchBox.Text = ""
End If
If (Eval("[Form]![SearchBox] Is Null Or [Form]![SearchBox]=""""")) Then
End
End If
If (VarType(.Form!SearchBox) <> 8) Then
End
DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
End If
If (Eval("([Form]![SearchBox] Is Null Or [Form]![SearchBox]="""") And [SearchClear].[Visible]<>0")) Then
DoCmd.SetProperty "SearchClear", acPropertyVisible, "0"
End
End If
' Handle "'s in search
TempVars.Add "strSearch", "Replace([Form]![SearchBox],"""""""","""""""""""")"
' Build the Filter for the Task list
If (.Form.Name = "Task List_new_1516") Then
TempVars.Add "strFilter", """([Title] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Task List_new_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Description] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Task List_new_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Status] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Task List_new_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Priority] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Task List_new_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Assigned To] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Task List_new_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([sender] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Task List_new_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([overdue] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
' Build the Filter for the Contact list
If (.Form.Name = "Contact List_1516") Then
TempVars.Add "strFilter", """([Discipline/Area] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Contact List_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([First Name] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Contact List_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([E-mail Address] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Contact List_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Company] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Contact List_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Job Title] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Contact List_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Notes] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
If (.Form.Name = "Contact List_1516") Then
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Zip/Postal Code] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
End If
' Apply the Filter
DoCmd.ApplyFilter "", TempVars!strFilter
TempVars.Remove "strFilter"
TempVars.Remove "strSearch"
DoCmd.SetProperty "SearchClear", acPropertyVisible, "-1"
DoCmd.GoToControl "SearchBox"
DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
End With
Search_Exit:
Exit Function
Search_Err:
MsgBox Error$
Resume Search_Exit
End Function