我有一个带有提交按钮的请求表。点击后,我想访问一下提交日期,以查看它是否大于今天的下午3:00。如果是,那么将显示一个消息框,供您更改请求的日期并重新提交。
这是我尝试过的,但出错了。
如果可能,请协助
Dim mDate As Date
mDate = DateValue(Me.tblEntered)
IIf (mDate > "3:00 pm")
If MsgBox("You are submitting a request after the 3:00 PM cutoff time. " & Chr(13) & _
"You should change your request to the next day. Do you want to change your request date?", vbYesNo + vbQuestion + vbDefaultButton2) = vbNo Then
DoCmd.Save
Else
MsgBox "Please make changes and resubmit"
End If
您的代码存在一些错误(缺少“ End If”,使用“ IIf”而不是“ If”,日期检查是/否)
我不知道您来源的格式/内容:Me.tblEntered是一个日期还是日期和时间?如果包含时间,请更改我的“日期+#3:00:00 PM#”
Dim mDate As Date
mDate = DateValue(Me.tblEntered)
If (mDate > Date + #3:00:00 PM#) Then ' Today at 3PM
If MsgBox("You are submitting a request after the 3:00 PM cutoff time. " & Chr(13) & _
"You should change your request to the next day. Do you want to change your request date?", vbYesNo + vbQuestion + vbDefaultButton2) = vbNo Then
DoCmd.Save
Else
MsgBox "Please make changes and resubmit"
End If
End If