Office中国论坛/Access中国论坛

标题: 请教一个关于dateadd的问题 [打印本页]

作者: sarfeilee    时间: 2008-4-3 11:24
标题: 请教一个关于dateadd的问题
请高手帮忙,现在有2个表,一个是HolidayDate,一个是AdditionalWorkingDay,分别代表节假日和原为休息日但由于节假日更改为工作日的日期,麻烦看一下这个dateadd 函数是否有问题,多谢。主要是有节假日就跳过,额外工作日则要加上。
Public Function DraftBFLDueDate(startdate As Variant, D As Variant) As Date
'On Error GoTo Err_DraftBFLDueDate

Dim intCount As Integer
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim rstAWD As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT [HolidayDate] FROM Holidays", dbOpenSnapshot)
Set rstAWD = db.OpenRecordset("SELECT [AdditionalWorkingDay] FROM AdditionalWorkingDay", dbOpenSnapshot)
intCount = 0

Do While intCount < D

rst.FindFirst "[HolidayDate] = #" & startdate & "#"
rstAWD.FindFirst "[AdditionalWorkingDay] = #" & startdate & "#"
If Weekday(startdate) <> vbSunday And Weekday(startdate) <> vbSaturday Or rstAWD.NoMatch = "false" Then
If rst.NoMatch Then intCount = intCount + 1
End If
startdate = startdate + 1
Loop

DraftBFLDueDate = startdate - 1

rst.Close
rstAWD.Close
'Exit_DraftBFLDueDate:

'Exit Function

'Err_DraftBFLDueDate:
'Select Case Err

'Case Else
'MsgBox Err.Description
'Resume Exit_DraftBFLDueDate
'End Select

End Function
作者: sarfeilee    时间: 2008-4-3 11:33
请高手快回答阿   急。。。。。。。。。。
作者: andymark    时间: 2008-4-3 11:52
把例子一起传上来,方便测试




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3