我有一个表格,用于输入在收到文书工作之日处理的文书信息。
我需要在一个名为firstFollowUp的新字段中,在dateReceived之后的8个工作日内生成一个日期,以跟踪文书工作的状态。
我最熟悉VBA,但是我愿意接受其他建议。
我在格式行上收到语法错误。另外,我不确定这是否能达到我的期望。
Function Work_Days(dateReceived As Variant, firstFollowUp As Variant) As Long
Dim wholeWeeks As Variant
Dim dateCount As Variant
Dim endDays As Integer
wholeWeeks = DateDiff("w", dateReceived, firstFollowUp)
dateCount = DateAdd("ww", wholeWeeks, dateReceived)
endDays = 0
Do While dateCount <= firstFollowUp
If Format(dateCount, "ddd")<> "Sun" And Format(dateCount, "ddd")<> "Sat" Then
endDays = endDays + 1
End If
dateCount = DateAdd("d", 1, dateCount)
Loop
Work_Days = wholeWeeks * 5 + endDays
Exit Function
假设DatePaperworkReceived
是您的“收到文书工作的日期”的表单控件,请将其添加到DatePaperworkReceived
的“ AfterUpdate”事件中。
[Me.firstFollowUp = DateAdd('d',8,Me.DatePaperworkreceived)] >>
对于工作日,您将使用:而不是8;
IIf(Weekday(Me.DatePaperworkreceived)=7,13,IIF(Weekday(Me.DatePaperworkreceived)>3,12,10))
如果可以放心,接收日期不会在周末,可以简化:
IIF(Weekday(Me.DatePaperworkreceived)>3,12,10)
我在一个旧的Access应用程序代码中找到了一个,该代码可以计算下一个工作日,但我不知道从哪里得到它。学分归谁的编码员。我可能会有用: