Access VBA - Return Date Range From Combo Box Selection

Posted on 2007-08-07
Medium Priority
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
  • 2
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 2000 total points
ID: 19650294

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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 19650297
you have to set the following for cboMonth

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Beware when using the ListIndex and the Column() properties of a listbox in Access 2007.  A bug has been identified in the Access 2007 listbox code which can cause the .ListIndex property to return a -1, and the .Columns(#) property to return a NULL…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

612 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