Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Date checking in default value 1

Status
Not open for further replies.

egobbitz

Programmer
Oct 18, 2002
47
US
Hello,
I have a table that stores entry information by date. We gather all entry info from Saturday, Sunday, and Monday as one day, and every other day as separate days. We input data from Friday on Monday, and Monday on Tuesday, etc. What I am trying to do is change the default date that appears when a user keys information into the table.
When the day is Monday, I would like the date field to have the previous Friday's date. Any other day would default to the previous day's date.

For example, if Monday is 5-5-2003 then I want the table to default to 5-2-2003. I have tried to use an IIF function, but it does not seem to be working. Can someone please tell me what I am doing wrong? Here is what I have so far....

IIf(DatePart("d",Date())=2,Date()-3,Date()-1)

The field has no other format specified other than it is a Date/Time field.

Any suggestions would be appreciated.
Thanks.

Nick
 
change your statement to use the "w" which is weekday.

IIf(DatePart("w",Date())=2,Date()-3,Date()-1)

You were using "d" which is the day of the month.

Bob Scriver
 
Thanks very much. I appreciate the quick response.

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top