Sequential Dates

  • Thread starter Thread starter Owen Wilson
  • Start date Start date
O

Owen Wilson

Hi,

I have a form onwhich data entered will end up on a
report called "Two Week Look Ahead". Among other things,
I have 14 text boxes that indicate the day of the year
that corresponds to a day of the week. The day of the
week will be in a label. I'd like to get the "Date of
the year" boxes to fill out automatically by reading the
report date and filling in the the next 14 dates.
Can this be done?

TIA

Owen
 
Hi Owen

You can add a certain number of days to a given date like this...

Either:
NewDate = DateAdd( "d", NumberOfDays, GivenDate )
or, less "correct" but faster:
NewDate = GivenDate + NumberOfDays

So, you could do something like this:

Dim iDay as Integer
' Assume ReportDate is known, and you have
' 14 textboxes named txtDay0 to txtDay13
For iDay = 0 to 13
Me("txtDay" & iDay) = ReportDate + iDay
Next iDay

Set the textbox Format properties to the date format of your choice.

Also, instead of labels for the day names, you could use textboxes with a
Format of "dddd" (the day name). Make each textbox disabled and locked and
set its ControlSource to the corresponding date textbox. For example:
txtDayName0: =[txtDay0]
and so on.
 
Back
Top