Next Day of the Week.

G

Guest

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,
 
G

Guest

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)
 
G

Guest

Hi Daniel,

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

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top