Validation Rule Problem

  • Thread starter Tom K via AccessMonster.com
  • Start date
T

Tom K via AccessMonster.com

Hi,
Im trying to enter a validation rule for two controls on my form. These
controls hold two dates. DateSent and DateReturned. My rule for DateSent is;
<[DateReturned]. Text is; Date sent must be before date returned. My rule for
DateReturned is; >[DateSent]. The problem is that when I try to put a date in
DateSent it pops up the validation rule and wont let me put it in , even if
it is before date returned or date returned is blank.

The fields may have had some value in then at one point but now they are
empty. Is there something in there that I cant see? They both have masks to
put in the dates, would that cause a problem? I should be able to put in a
date into date sent before date returned has has any value. Is there a
different way to put in the expression?

Thanks

Tom
 
A

Arvin Meyer [MVP]

You can add:

Or Is Null

to the validation rules. Unfortunately validation rules won't let you check
conditions in code, so you may want to use the form's or control's
BeforeUpdate event something like (aircode):

Sub DateSent_BeforeUpdate(Cancel As Integer)

If Len(Me.DateReturned) > 0 Then
If Me.DateSent > Me.DateReturned Then
MsgBox "No way Jose!"
Me.DateSent.SetFocus
Cancel = True
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
T

Tom K via AccessMonster.com

Thanks,

Where would I use the Or Is Null? I tried =[DateReturned] Is Not Null And
[DateSent]<[DateReturned], but it didn't work either.

Thanks for the help

Tom
You can add:

Or Is Null

to the validation rules. Unfortunately validation rules won't let you check
conditions in code, so you may want to use the form's or control's
BeforeUpdate event something like (aircode):

Sub DateSent_BeforeUpdate(Cancel As Integer)

If Len(Me.DateReturned) > 0 Then
If Me.DateSent > Me.DateReturned Then
MsgBox "No way Jose!"
Me.DateSent.SetFocus
Cancel = True
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
Hi,
Im trying to enter a validation rule for two controls on my form. These
[quoted text clipped - 13 lines]
 
A

Arvin Meyer [MVP]

Try: <=[DateReturned] Or Is Null
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Tom K via AccessMonster.com said:
Thanks,

Where would I use the Or Is Null? I tried =[DateReturned] Is Not Null And
[DateSent]<[DateReturned], but it didn't work either.

Thanks for the help

Tom
You can add:

Or Is Null

to the validation rules. Unfortunately validation rules won't let you check
conditions in code, so you may want to use the form's or control's
BeforeUpdate event something like (aircode):

Sub DateSent_BeforeUpdate(Cancel As Integer)

If Len(Me.DateReturned) > 0 Then
If Me.DateSent > Me.DateReturned Then
MsgBox "No way Jose!"
Me.DateSent.SetFocus
Cancel = True
End If
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
Hi,
Im trying to enter a validation rule for two controls on my form. These
[quoted text clipped - 13 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top