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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with retaining dates on form

Status
Not open for further replies.

bwedmund

Technical User
Oct 29, 2000
17
US
I have a form where a date is entered every Monday. This form is used during the day all week long. Is there a way to have the form keep the "Monday" date until the next Monday.

Thanks
 
You can set the default value of a text box as follows:

Me.txtDateInput.DefaultValue = Date()

You could run that snippet of code with a command button which your users could be instructed to click each monday.

You could get trickier by examining the date each time the form is opened and if it's Monday then set the default value. Look at help for WeekDay() "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
This code will give you the previous Monday's date..


=IIf(DatePart("w",Date(),2,2)="1",DateAdd("w",-0,Date()),IIf(DatePart("w",Date(),2,2)="2",DateAdd("w",-1,Date()),IIf(DatePart("w",Date(),2,2)="3",DateAdd("w",-2,Date()),IIf(DatePart("w",Date(),2,2)="4",DateAdd("w",-3,Date()),IIf(DatePart("w",Date(),2,2)="5",DateAdd("w",-4,Date()),IIf(DatePart("w",Date(),2,2)="6",DateAdd("w",-5,Date()),IIf(DatePart("w",Date(),2,2)="7",DateAdd("w",-6,Date()))))))))


Sean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top