将dateReceived字段后的八个工作日生成日期到我的表单的firstFollowUp字段中

问题描述 投票:0回答:2

我有一个表格,用于输入在收到文书工作之日处理的文书信息。

我需要在一个名为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
ms-access access-vba
2个回答
0
投票

假设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)

0
投票

我在一个旧的Access应用程序代码中找到了一个,该代码可以计算下一个工作日,但我不知道从哪里得到它。学分归谁的编码员。我可能会有用:

© www.soinside.com 2019 - 2024. All rights reserved.