Weekend 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
 
D

dingocal

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top