Full Version: Previous Working Day
UtterAccess Discussion Forums > Microsoft® Access > Access Date + Time
ping
I have written a database, but as the data is input the day after the event (on the whole), I am trying to make it so it defaults to the previous working day, all was going well, when I thought I would be really smart and think about Mondays, so I have put in this code, which goes on "NEW RECORD BUTTON". I am not worried about Bank Holidays etc, that can be overtyped, it would be just nice if from Monday to Friday.

Many thanks in advanced, I have trawled the Archives, but to no avail.

DoCmd.GoToRecord , , acNewRec

If Weekday(Date, vbMonday) Then
Me.DateIssued = DateAdd("d", -3, Date)

Else
Me.DateIssued = DateAdd("d", -1, Date)

End If
hdlee
Add this to "Default Value" property of the text box.

=IIf(Weekday(Date())=2,DateAdd("d",-3,Date()),DateAdd("d",-1,Date()))
ping
Thank you - that is exactly what I wanted, I tried that first, but was going it much more confusingly than that and was getting myself in knots.

Regards,
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.