Access VBA - Return Date Range From Combo Box Selection

Posted on 2007-08-07
Last Modified: 2013-11-27
I have two combo boxes: 1 - cboMonth displays the month and 2 - cboYear displays the year.

I've been trying to return date ranges for all combo values...i.e.

September 2007 returns 09/01/2007 to 09/30/2007 and
December 2006 returns 12/01/2006 to 12/31/2006

Is there any calandar type control (or other function etc) that can do this
Question by:advlegals
    LVL 119

    Accepted Solution


    do you mean, you want all the dates for the whole month selected?

    what is the rowsource of cboMonth?
    if you have a table for month tblMonth with fields
    ID and MonthName
    1         January
    2         February
    12      December

    and use this as row source

    select id,MonthName from tblMonth

    you can easily get the ranges of dates

    dim firstDate as date,lastDate as Date

    firstdate=me.cboMonth &"/1/" & me.cboYear
    lastdate=dateserial(Year(firstdate),Month(firstdate) +1,0)

    LVL 119

    Expert Comment

    by:Rey Obrero
    you have to set the following for cboMonth

    bound column  1
    column count   2
    column width   0";1

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    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…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    730 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

    16 Experts available now in Live!

    Get 1:1 Help Now