From: smartcookie on
I am kind of beating my head over this problem.

I am trying to create a rule by where the user cannot enter data if todays
date is greater than a function date - max time given in a query

So lets say the user has 72 hrs to respond before an event date lets say Jan
1, 2010.

I tried this so far but its not working :

EventDatePlusMaxTime: DateDiff("n",[functiondate]+[maxtime],[functiondate])


From: John W. Vinson on
On Fri, 26 Mar 2010 14:57:01 -0700, smartcookie
<smartcookie(a)discussions.microsoft.com> wrote:

>I am kind of beating my head over this problem.
>
>I am trying to create a rule by where the user cannot enter data if todays
>date is greater than a function date - max time given in a query
>
>So lets say the user has 72 hrs to respond before an event date lets say Jan
>1, 2010.
>
>I tried this so far but its not working :
>
>EventDatePlusMaxTime: DateDiff("n",[functiondate]+[maxtime],[functiondate])
>
>

Use DateAdd instead of DateDiff, in the form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Date() > DateAdd("h", [maxtime], [functiondate]) Then
MsgBox "Sorry, time limit has elapsed", vbOKOnly
Cancel = True
End If
End Sub

--

John W. Vinson [MVP]
 | 
Pages: 1
Prev: Troubleshoot A Query
Next: Query Problem