From: Golfinray on
My managers keep putting dates in a text field. Is there any way to use
validation where they can't put dates in a text field or n/a or some other
comment in a date field? I have all the datatypes set but they still manage
to enter stuff in the wrong place on the form and it then ends up in the
table. Thanks so much!!!!
From: Jeff Boyce on
If IsDate([YourControl]) Then ...

Else

End If

"Golfinray" <Golfinray(a)discussions.microsoft.com> wrote in message
news:2B829340-EAE7-4991-83EE-99687F54E58C(a)microsoft.com...
> My managers keep putting dates in a text field. Is there any way to use
> validation where they can't put dates in a text field or n/a or some other
> comment in a date field? I have all the datatypes set but they still
> manage
> to enter stuff in the wrong place on the form and it then ends up in the
> table. Thanks so much!!!!


From: John W. Vinson on
On Tue, 1 Jul 2008 06:49:00 -0700, Golfinray
<Golfinray(a)discussions.microsoft.com> wrote:

>My managers keep putting dates in a text field. Is there any way to use
>validation where they can't put dates in a text field or n/a or some other
>comment in a date field? I have all the datatypes set but they still manage
>to enter stuff in the wrong place on the form and it then ends up in the
>table. Thanks so much!!!!

If they are putting something like "This is due on 7/25" into a text field,
then it will be pretty complicated to prevent!

You can use the textbox's BeforeUpdate event on a form to trap cases where
they're putting *just* a date:

Private Sub controlname_BeforeUpdate(Cancel as Integer)
If IsDate(Me!controlname) Then
MsgBox "Please put dates in the date field, not here", vbOKOnly
Cancel = True
<if you want to be nice then>
Me!datefield = Me!controlname ' copy what they entered
Me!controlname.Undo
End If
End Sub

--

John W. Vinson [MVP]