Results 1 to 6 of 6
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    Filter not effective

    I have a report where its code sheet is coded as follows:

    Option Compare Database
    Option Explicit
    Dim Indate As Date
    Const Prompt As String = "Enter date after which funds have been received" & vbNewLine & _
    "and which are now subject to deposit."

    Private Sub Report_Open(Cancel As Integer)
    Me.lblHeader.Caption = "Registrar's Bank Deposits for " & gblRetreatYear

    Indate = InputBox(Prompt, "Deposit Summary Report")
    Me.lblDepositDate.Caption = "(For funds received after " & Indate & " )"

    Me.Filter = "RetYear = " & """" & gblRetreatYear & """" & " AND RecDate > " & Indate
    Debug.Print Me.Filter
    Me.FilterOn = True
    End Sub


    In the immediate window, the value for Me.Filter is: RetYear = "2013" AND RecDate > 03/19/2013

    "RetYear" is text and "RecDate" is date, as included in the RecordSource query for the report. gblRetreatYear is global and is Dim'd as text.

    The report IS NOT being filtered to exclude "RecDates" prior to "03/19/2013", as entered via InputBox.

    What am I missing here?



    Thanks,
    Bill

  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,518
    Try

    Me.Filter = "RetYear = " & """" & gblRetreatYear & """" & " AND RecDate > #" & Indate & "#"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Paul,
    That did the trick.
    WOW! That's a new one on me. The use of pound (#) suggests clarification of formatting. Is that what's going on here?
    Bill

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The # is generally needed as a delimiter for a date value. Quotes for text, # for dates, nothing for numbers. You'll notice in a query if you type in a date as a criteria on a date/time field, Access will add the #.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    You realize you're getting closer to a FREE lunch.
    Thanks,
    Bill

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Don't toy with me Bill.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 5
    Last Post: 02-07-2013, 12:21 PM
  2. Replies: 1
    Last Post: 08-16-2012, 01:51 PM
  3. Correct tables for an effective database
    By Sillub in forum Database Design
    Replies: 6
    Last Post: 08-04-2012, 09:21 PM
  4. Apply Filter similar to Field Filter
    By DatabaseIntern in forum Forms
    Replies: 1
    Last Post: 06-11-2012, 05:42 PM
  5. Replies: 28
    Last Post: 03-08-2012, 06:47 PM

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