Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

filtering a subform from a main form

Posted on 2011-03-24
3
Medium Priority
?
225 Views
Last Modified: 2012-05-11
I have an access 2002 database with a filter/search form and subform, but when I try to filter it by date it just clears all of the entries without showing the filtered info. the other filters all work it is just the date one that does not work.

this is the line of code for the date filter.
Filter_Date = IIf(Forms.Equipment_Query_Form.Date_Search <> "", "Validated_Date = " & Forms.Equipment_Query_Form.Date_Search & " and ", "")

this is the code for one of the other filters that works OK
Filter_Model = IIf(Forms.Equipment_Query_Form.Model_Search <> "", "Model = '" & Forms.Equipment_Query_Form.Model_Search & "' and ", "")
Private Sub Run_Search()
Dim Equipment_Query_Subform_Form_Filter, Filter_Date, Filter_Review, Filter_Status, Filter_Equipment, Filter_Model, Filter_Condition
Equipment_Query_Subform.Form.Filter = ""

'DEFINE FILTERS
Filter_Date = IIf(Forms.Equipment_Query_Form.Date_Search <> "", "Validated_Date = " & Forms.Equipment_Query_Form.Date_Search & " and ", "")
Filter_Review = IIf(Forms.Equipment_Query_Form.Review_Search <> "", "Validation_Review_Date = " & Forms.Equipment_Query_Form.Review_Search & " and ", "")
Filter_Status = IIf(Forms.Equipment_Query_Form.Status_Search <> "", "Validation_Status = '" & Forms.Equipment_Query_Form.Status_Search & "' and ", "")
Filter_Equipment = IIf(Forms.Equipment_Query_Form.Equipment_Search <> "", "Equipment_Description = '" & Forms.Equipment_Query_Form.Equipment_Search & "' and ", "")
Filter_Model = IIf(Forms.Equipment_Query_Form.Model_Search <> "", "Model = '" & Forms.Equipment_Query_Form.Model_Search & "' and ", "")
Filter_Condition = IIf(Forms.Equipment_Query_Form.Condition_Search <> "", "Equipment_Condition = '" & Forms.Equipment_Query_Form.Condition_Search & "' and ", "")

Equipment_Query_Subform.Form.FilterOn = False
Equipment_Query_Subform_Form_Filter = Filter_Date + Filter_Review + Filter_Status + Filter_Equipment + Filter_Model + Filter_Condition

If Equipment_Query_Subform_Form_Filter <> "" Then Equipment_Query_Subform_Form_Filter = Mid(Equipment_Query_Subform_Form_Filter, 1, Len(Equipment_Query_Subform_Form_Filter) - 5) ' remove ' and'

Equipment_Query_Subform.Form.Filter = Equipment_Query_Subform_Form_Filter
If Equipment_Query_Subform_Form_Filter <> "" Then
        Me.Day_report_search_filter = Equipment_Query_Subform_Form_Filter
        Equipment_Query_Subform.Form.FilterOn = True
    Else: Equipment_Query_Subform.Form.FilterOn = False
    Me.Day_report_search_filter = "#"
End If

End Sub

Open in new window

0
Comment
Question by:Scubalad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
hnasr earned 2000 total points
ID: 35209800
Try:
Filter_Date = IIf(Forms.Equipment_Query_Form.Date_Search <> "", "Validated_Date = #" & Forms.Equipment_Query_Form.Date_Search & "# and ", "")
0
 

Author Comment

by:Scubalad
ID: 35213226
Hi hnasr, Thanks for the very prompt and helpful answer I have been looking at that line for so long and I kept missing the # signs.
0
 
LVL 31

Expert Comment

by:hnasr
ID: 35213718
Welcome!
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question