Next Day of the Week.

S

sap4ora

Hello,
I have a form that uses a “testDate†as a Date. I’m looking to have another
field “auditDate†that will always be the Tuesday that follows the “testDateâ€.
Any help would be great.

Thanks,
 
D

Daniel

Try the following

Function FindNextDay(dtDate As Variant) As Variant

For I = 1 To 6
dtDate = DateAdd("d", 1, dtDate)
If Weekday(dtDate) = vbTuesday Then
FindNextDay = dtDate
Exit For
End If
Next I

End Function

In yours case you'll call the fundtion using testDate as an input variable

dtNextTuesday = FindNextDay(Me.testDate)
 
S

sap4ora

Hi Daniel,

This works but you'll need to add:
Dim I As Integer
and
For I = 1 To 7

Thanks,
 
Top