Results 1 to 5 of 5
  1. #1
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35

    Question Search Date Range by month in a Combo Box within a Form?

    Hello, I'm trying to create a combo list box in a form that has all 12 months (January, February......etc,) listed in rows, and depending on the selection will bring up only that particular month within a range of dates from a table. I don't want it to look at the day or the year, but only the month.
    Example: I select January from the drop down list in my combo box and my form will display all records with dates that are in January regardless of month or year.
    Any help with this would be greatly appreciated. Thanks



    Click image for larger version. 

Name:	Example.jpg 
Views:	34 
Size:	176.1 KB 
ID:	7813

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    How do you want to execute the filter? Parameterized query or set form filter property in VBA?

    Me.FilterOn = False
    Me.Filter = "Format([Birth Date],"mmmm")='" & Me.comboboxname
    Me.FilterOn = True
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK, the combo box row source would be either a table with two fields
    MthNumber Integer
    MthName Text

    and the row source for the combo box would be
    SELECT MthNumber, MthName FROM tblMonths ORDER BY MthNumber;

    Set the properties of the combo box to:
    Limit to List = TRUE
    Column count = 2
    Column Widths = 0";1"
    List Rows = 13


    --------------
    OR

    a value list (I prefer this):
    ;"All";1;"January";2;"February";3;"March"; .....;12;"December"

    Set the properties of the combo box to:
    Row source type = Value List
    Column count = 2
    Column Widths = 0";1"
    List Rows = 13



    The query for the form would be :
    Code:
    SELECT Employees.EmpLName, Employees.EmpDOB
    FROM Employees
    WHERE (((Month([empdob]))=[forms]![Form7].[cboMonth])) OR ((([forms]![form7].[cboMonth]) Is Null));
    In the after update event of the combo box:
    Code:
    Private Sub cboMonth_AfterUpdate()
       Me.Requery
    End Sub



    Change the BLUE terms to your field/table/combo box names.

  4. #4
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35
    Hello Steve, THANK YOU, THANK YOU and THANK YOU again, I have been messing with this for a week now, and I finally got it to work.
    Your help was truly appreciated. I used the Value List with the Query & Code.

    Have a wonderful Memorial Day Weekend.

    Claudia

  5. #5
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35
    Great forum, thank you June7 & ssanfu for your help, I got it working now

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

Similar Threads

  1. Replies: 21
    Last Post: 04-29-2015, 11:57 PM
  2. Replies: 1
    Last Post: 04-20-2012, 03:16 AM
  3. Date Range on Form
    By normie in forum Access
    Replies: 16
    Last Post: 03-13-2012, 08:57 PM
  4. Date range query from form
    By Steve Barnes in forum Queries
    Replies: 2
    Last Post: 07-29-2010, 07:06 PM
  5. Search form with a date range
    By mantro174 in forum Forms
    Replies: 1
    Last Post: 02-11-2009, 10:45 PM

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