I've got a form with a bound control - REP_DATE. When the form opens, I want
this control populated with the next day's date, unless the next day is
Saturday. In that case, I want the next Monday's date entered into the
control. Can somebody show me the syntax of how that happens? Thanks...
Private Sub Form_Load()
Select Case Weekday(Date())
Case vbFriday
Me!REP_DATE = DateAdd("d", 3, Date())
Case vbSaturday
Me!REP_DATE = DateAdd("d", 2, Date())
Case Else
Me!REP_DATE = DateAdd("d", 1, Date())
End Select
End Sub

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> I've got a form with a bound control - REP_DATE. When the form opens, I
> want
> this control populated with the next day's date, unless the next day is
> Saturday. In that case, I want the next Monday's date entered into the
> control. Can somebody show me the syntax of how that happens? Thanks...
Don - 29 May 2007 21:38 GMT
Thank you, this was helpfull.

Signature
Don Rountree
> Private Sub Form_Load()
>
[quoted text clipped - 14 lines]
> > Saturday. In that case, I want the next Monday's date entered into the
> > control. Can somebody show me the syntax of how that happens? Thanks...
> I've got a form with a bound control - REP_DATE. When the form opens, I
> want
> this control populated with the next day's date, unless the next day is
> Saturday. In that case, I want the next Monday's date entered into the
> control. Can somebody show me the syntax of how that happens? Thanks...
In Form_Current:
Me.REP_DATE = IIf(Weekday(DateAdd("d", 1, Date)) = 7, DateAdd("d", 3,
Date), DateAdd("d", 1, Date))
Carl Rapson
Don - 29 May 2007 21:37 GMT
Thank you, this was helpful.

Signature
Don Rountree
> > I've got a form with a bound control - REP_DATE. When the form opens, I
> > want
[quoted text clipped - 8 lines]
>
> Carl Rapson
Marshall Barton - 30 May 2007 01:28 GMT
>In Form_Current:
>
> Me.REP_DATE = IIf(Weekday(DateAdd("d", 1, Date)) = 7, DateAdd("d", 3,
>Date), DateAdd("d", 1, Date))
no, No, NO!
You should ***NEVER*** set a bound control or field's value
in the Current event.
If you do, simply navigating through the records in the form
will dirty and save every record that you look at,
eventually leading to all kinds of catestrophic failures.

Signature
Marsh
MVP [MS Access]