0
我得到一个错误,如果条件(我猜日期差异),但我想不出原因。Microsoft Access VBA Datediff错误
错误状态:无效的过程调用或参数。
现在:格式为DD.MM.YYYY HH当前系统时间:MM:SS
原点:是从格式DD.MM.YYYY HH表的日期:MM :SS
Public Function ImportDateCheckSpec(eing As String) As error
Dim datum As Date
Dim error As New error
error.Success = True
error.Code = 2
error.Message = "There has been a problem with the given Date. This might be due to:" + vbCrLf + " *The date is befor the current date. " + vbCrLf + " *The date is in the wrong format."
Debug.Print 4
On Error GoTo Fail
datum = CDate(eing)
Debug.Print datum
Debug.Print Now
If (DateDiff("Day", Now, datum) < 0) Then '<----- Here is the error
Debug.Print 2
error.Success = False
Set ImportDateCheckSpec = error
End If
Exit Function
Fail:
Debug.Print 3
error.Success = True
Set ImportDateCheckSpec = error
Exit Function
End Function
'Day'是无效的:'则DateDiff( “d”,现在,基准)' - 注意' “99999”'会通过你的测试... –
'Error'是关键词,强烈建议您用其他方法改变它。最好在模块声明中使用'Option Explicit'。转到选项>>需要变量声明才能激活它。 –
谢谢,为什么“99999”会通过? – Lukas