InFlight
User
- Local time
- Today, 16:41
- Joined
- Jun 11, 2015
- Messages
- 130
Hi
I used "Convert form's Macros to Visual Basic" but i am getting errors in the If(eval) line.
I have a text field called SearchBox on a form called Suppliers
I used "Convert form's Macros to Visual Basic" but i am getting errors in the If(eval) line.
I have a text field called SearchBox on a form called Suppliers
Code:
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 "iconSearchClear", acPropertyVisible, "0"
DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
DoCmd.SetProperty "iconSearchGo", 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
End If
DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
DoCmd.SetProperty "iconSearchGo", acPropertyVisible, "-1"
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(Forms![Contact List]!SearchBox, """", """""")
' Build the Filter
TempVars.Add "strFilter", "([Last Name] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([First Name] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([E-mail Address] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([Company] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([Job Title] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([Category] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([Zip/Postal Code] Like "" * " & [TempVars]![strSearch] & " * "" )"
DoCmd.ApplyFilter "", TempVars!strFilter, ""
TempVars.Remove "strFilter"
TempVars.Remove "strSearch"
DoCmd.SetProperty "SearchClear", acPropertyVisible, "-1"
DoCmd.SetProperty "iconSearchClear", acPropertyVisible, "-1"
DoCmd.GoToControl "SearchBox"
DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
DoCmd.SetProperty "iconSearchGo", acPropertyVisible, "-1"
End With
Search_Exit:
Exit Function
Search_Err:
MsgBox Error$
Resume Search_Exit
End Function
'------------------------------------------------------------
' Search_ClearFilter
'
'------------------------------------------------------------
Function Search_ClearFilter()
On Error GoTo Search_ClearFilter_Err
With CodeContextObject
' Clear Filter
DoCmd.ApplyFilter "", """""", ""
DoCmd.GoToControl "SearchBox"
DoCmd.SetProperty "SearchClear", acPropertyVisible, "0"
DoCmd.SetProperty "iconSearchClear", acPropertyVisible, "0"
DoCmd.SetProperty "SearchGo", acPropertyVisible, "-1"
DoCmd.SetProperty "iconSearchGo", acPropertyVisible, "-1"
If (CurrentProject.IsTrusted) Then
.SearchBox = ""
End If
Exit Function
End With
Search_ClearFilter_Exit:
Exit Function
Search_ClearFilter_Err:
MsgBox Error$
Resume Search_ClearFilter_Exit
End Function