Date validation (if today - 1 week then)

morlan

Registered User.
Local time
Today, 18:01
Joined
Apr 23, 2003
Messages
143
Sorry for another Date validation question.

I've done some searching but I cant find what I'm loooking for.


I need a validation rule that would make sure the date entered was not older that 1 week from todays date.

I have a field 'txtDateTimeKeyed' which contains the current date and time from the SQL server so I wont be using now()

Please can you help?
 
How about this?

Between txtDateTimeKeyed And DateAdd("d", 7, txtDateTimeKeyed)


or some such variation.
 
Last edited:
*GRMBL*

You and your dateadd... *SIGH* :)

txtDateTimeKeyed+7

Will do the same...

Regards
 
Thank Mile, how do I implement this in VB? Or is it just for SQL?

EG. Is it like:

IF ME.txtAppDate.Value Between txtDateTimeKeyed And DateAdd("d", 7, txtDateTimeKeyed) then "TO OLD"
 
IF ME.txtAppDate Between txtDateTimeKeyed And DateAdd("d", 7, txtDateTimeKeyed) then Msgbox "TO OLD"

But you can also put the between bit directly as a validation rule.

Regards
 
The vb is not liking the BETWEEN bit. Is says: Compile error. Expected Then or Goto? Any ideas
 
Between And is an SQL syntax.

Code:
If Me.txtAppDate > = txtDateTimeKeyed And _
    Me.txtAppDate <= DateAdd("d", 7, Me.txtDateTimeKeyed) Then
    Msgbox "TOO OLD" 
End If
 

Users who are viewing this thread

Back
Top Bottom