Results 1 to 4 of 4
  1. #1
    emilyrogers is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2010
    Posts
    46

    Question Filtering Dates Error!


    I have a filter that filter through all of my records to find those that match all criteria in the filter.
    However this section of code is used to filter 2 date range criteria.
    Code:
    If (strWhere <> "") Then strWhere = "(" & Mid(strWhere, 6) & ")"
            
        If (Chk_log_date) And Not (IsNull(DT_log_date1.Value)) Then
                strDate = " AND [Opportunities].[Bid Required By] >= " & _
                "#" & Format$(DT_log_date1.Value, "mm/dd/yyyy") & "#"
            End If
            If Not (IsNull(DT_log_date2.Value)) Then
                strDate = strDate & " AND [Opportunities].[Bid Required By] <= " & _
                "#" & Format$(DT_log_date2.Value, "mm/dd/yyyy") & "#"
            End If
        
           
                
        If (Check191) And Not (IsNull(ActiveXCtl194.Value)) Then
                strDate = " AND [Opportunities].[Enquiry Date] >= " & _
                "#" & Format$(ActiveXCtl194.Value, "mm/dd/yyyy") & "#"
            End If
            If Not (IsNull(ActiveXCtl195.Value)) Then
                strDate = strDate & " AND [Opportunities].[Enquiry Date] <= " & _
                "#" & Format$(ActiveXCtl195.Value, "mm/dd/yyyy") & "#"
            End If
      
        
        If (strWhere <> "") Then
          strWhere = strWhere & strDate
        Else
          strWhere = Mid(strDate, 6)
        End If
        If (strWhere <> "") Then strSQL = strSQL & "WHERE " & strWhere
    When used seperately (eg when Enquiry Date is used in the filter without bid required being included in the filter criteria) they work fine. however when used together the data is only filtered for "enquiry date" AND NOT " BID REQUIRED BY"

    Does anybody know why this is happening??

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This line:

    strDate = " AND [Opportunities].[Enquiry Date] >= " & _

    is not carrying forward the existing contents of the variable.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    emilyrogers is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2010
    Posts
    46
    How should I change it to make it correct?? sorry! Access novice!


    strDate = strDate " AND [Opportunities].[Enquiry Date] >= " &

    would this be right??

  4. #4
    emilyrogers is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2010
    Posts
    46
    Thank you so much!! It works!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Mixed dates - show only complete dates?
    By weeblesue in forum Queries
    Replies: 3
    Last Post: 10-27-2010, 02:15 PM
  2. Replies: 13
    Last Post: 09-27-2010, 03:10 PM
  3. filtering
    By nashr1928 in forum Forms
    Replies: 12
    Last Post: 07-01-2010, 06:30 AM
  4. Filtering Report with between dates
    By patrickmcdiver in forum Reports
    Replies: 3
    Last Post: 02-22-2010, 12:11 PM
  5. Filtering my report
    By ldarley in forum Reports
    Replies: 1
    Last Post: 09-05-2008, 09:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums