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

Add +1 Day, but skip weekend 1

Status
Not open for further replies.

Roblin

Technical User
Feb 3, 2005
26
US
I have a form with a field called cbostartdate. When you advance to the next record 1 day is added to the current date by this code:

Dim NextDate As Date
NextDate = cboStartDate
DoCmd.GoToRecord , , acNext
If NewRecord Then
cboStartDate.Value = NextDate + 1

Is there a way to prevent the date advancing to a saturday or sunday? If I enter data on a monday and continue throug the week on Friday the next date appearing is of course Saturday. I would like it to skip the Saturday and Sunday and give the next Monday's date. I use a pop up calendar to choose the start date initially, but after that I want each new record to have a sequential date skipping the weekend. Any ideas?
 
Something like this ?
If Me.NewRecord Then
Do
NextDate = NextDate + 1
Loop Until WeekDay(NextDate, 2) < 6
cboStartDate.Value = NextDate
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Great!! It works. Thanks so much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top