Results 1 to 3 of 3
  1. #1
    SepieSmith is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    10

    Button to filter a form for current month and year

    Hello everyone,
    For the life of me - I have no idea why this code returns records "year-to-date" instead of just the current month. I've been beating my head for 2 days trying to find something else on the net but everyone seems to be answering the same thing I coded - only that for everyone else it seems to work!



    any thought what I should change in order to get records just from the current month (and current year) ?

    Private Sub btnCurrentMonth_Click()

    Me.Filter = "[QuoteSent] =" & True & " And [NoPotential]=" & False & " And [DocsReceived]=" & False & " And [LeadDate] Between #" & DateSerial(Year(Date), Month(Date), 1) & "# And #" & DateSerial(Year(Date), Month(Date), 31) & "#"

    Me.FilterOn = True
    End Sub

    Thank you in advance!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Maybe something like:
    Code:
    "[QuoteSent] =" & True & " And [NoPotential]=" & False & " And [DocsReceived]=" & False & " And Year([LeadDate]) = Year(Now()) And Month([LeadDate]) = Month(Now())"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    SepieSmith is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    10
    OMG! this is so embarrassing! Thank you Bob!!

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

Similar Threads

  1. Month/Year Filter on Continuous Form
    By doyouwantabedbath in forum Forms
    Replies: 1
    Last Post: 03-17-2016, 01:47 PM
  2. Replies: 4
    Last Post: 07-13-2015, 02:06 PM
  3. Get first day and month of current year
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 12-01-2014, 06:45 PM
  4. Replies: 6
    Last Post: 05-05-2014, 10:51 PM
  5. Filter Form records By Month Year
    By maxmaggot in forum Forms
    Replies: 4
    Last Post: 04-05-2013, 06:34 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