Solved

filtering a subform from a main form

Posted on 2011-03-24
3
218 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
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 500 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 30

Expert Comment

by:hnasr
ID: 35213718
Welcome!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

943 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now