filter

masoud_sedighy

Registered User.
Local time
Today, 12:00
Joined
Dec 10, 2011
Messages
132
In my form I have one unbound text box that it has 2 values (null or "overdue") according to its control source.

Expression control source: IIf(Int([Due Date])<Int(Date()),"Overdue")

Now when I want to filter my form (for example records are "overdue") with search box bottom at the top of form and related macro When I click search button I received message “enter parameter value”.
For filtering other fields I do not have problem and it works.

Part of macro expression for search button click is:
[TempVars]![strFilter] & " OR ([overdue] Like ""*" & [TempVars]![strSearch] & "*"")"​
Fields of form:​
Id
Date
Title
Start date
Due date
Overdue
Please help what is the problem
 
overdue parameter.but when i entered data "overdue" nothing happens (no filter).actually i do not know for calculated fields (unbound text box with control source) in the form filtering is possible or no?

now i made query and used expression property of unbound text box in that (new field). so i used record source of my form with this query, now i could filter my form.

best regards.
 
No it's not possible with calculated values in textboxes. You can always move the calculation to the query instead.

Can you convert the macro to VBA and paste it here.
 
actually i use template of task management.acct Microsoft acees 2007.and i like to customize that.

Code:
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
 
Last edited:

Users who are viewing this thread

Back
Top Bottom