Weekend date

  • Thread starter Thread starter CAM
  • Start date Start date
C

CAM

Hello,

In my form I have a command button that automaticlly populates a date text
box which use the system date less one day (see code below). For example
if the user press the command today (March 1, 2007) the date text box get
populated 2/28/2007. But here is my problem. If the user press the command
button on February 26, 2007, which is a Monday the date text box will
display February 25, 2007 a Sunday, but what I want is Fridays date February
23, 2007 instead. How can I have the date text populate to the previous
friday when the date is on a Monday? and How do I code it on my form?
Thank you in advance.


me.txtClaimsDate = Date - 1
 
CAM,

Try this:

me.txtClaimsDate = IIf(Weekday(Date)=2,Date-3,Date-1)

This assumes that your default first day of week is unchanged (and still set
to vbSunday).
 
Back
Top