Dates in a Combo Box

  • Thread starter Thread starter Michael Comtois
  • Start date Start date
M

Michael Comtois

Is there an easy way to make a combo box that always has
today's date first through 2 months from now? I am using
Access 2002. Thanks!

Mike
 
It is possible by using a Call-Back function (check Access Help on ComboBox
about special function you can use to create the RowSource for the
ComboBox).

OTOH, it sounds like a Calendar Control may be more suitable in this case.

HTH
Van T. Dinh
MVP (Access)
 
I haven't seen a question like this in years, and there
was an almost identical one yesterday.
School Project?

If you want the combo to return the 2 months of dates,
starting with the curent date:

Set the Combo Box's RowSource Type to Value List.
Set the Columns Count to 1
Set the Bound Column to 1
Set the Column Widths to 1"
Leave the RowSource blank.

In the Forms Load event:

Dim intY As Integer
Dim intX As Integer
Dim strRowSource As String
' Find how many days in this and the next month's.
intY = DateDiff("d", Date, DateAdd("m", 2, Date))
For intX = 0 To intY
strRowSource = strRowSource & Date + intX & ","
Next intX
Text227.RowSource = Left(strRowSource, Len(strRowSource) - 1)

When you first open the form the combo will fill with the 2 months of dates.
 
Back
Top