Hi Nickm,
on the BeforeUpdate event of the control:
'~~~~~~~~~~~~~~~~~~~~~``
if not IsDate(me.activecontrol) then
msgbox "You must enter a date",,"Cannot continue
cancel = true
end if
if not year(me.activecontrol) <> year(date()) then
msgbox "Year is incorrect, must be current year",,"Cannot continue
cancel = true
end if
'~~~~~~~~~~~~~~~~~~~~~``
Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
> I have a text box entry where the month, Day and year "OTDLdaTe" in required,
> but after reviewing the data in the table I noticed that the year entry may
[quoted text clipped - 3 lines]
>
> Thanks.
Nick - 07 May 2007 14:28 GMT
I have entered as you suggested but code does not work. I should tell you
that this in a sub form in a form footer.
> Hi Nickm,
>
[quoted text clipped - 29 lines]
> >
> > Thanks.
ruralguy - 07 May 2007 15:01 GMT
When you say it "does not work", what does it do? Does it display an error?
Did you put Crystal's code in the BeforeUpdate event of the control that is
used to enter the date? This *is* a visible control isn't it? The user keys
in the date into this control correct?
>I have entered as you suggested but code does not work. I should tell you
>that this in a sub form in a form footer.
[quoted text clipped - 4 lines]
>> >
>> > Thanks.

Signature
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.
Nick - 07 May 2007 15:37 GMT
When I keyed an incorrect year, I did not receive an error message asking for
the the correct year. It accepted the date entered. I did enter code in the
BeforeUpdate event.
> When you say it "does not work", what does it do? Does it display an error?
> Did you put Crystal's code in the BeforeUpdate event of the control that is
[quoted text clipped - 9 lines]
> >> >
> >> > Thanks.
ruralguy - 07 May 2007 16:51 GMT
Try replacing the Me.ActiveControl with the actual name of your control.
Crystal gave you generic code and we should try specific code. You might
also put a diagnostic MsgBox at the beginning of the BeforeUpdate event to
make sure it is running properly.
MsgBox "The input date is [" & Me.ControlName & "]"
using your ControlName of course.
>When I keyed an incorrect year, I did not receive an error message asking for
>the the correct year. It accepted the date entered. I did enter code in the
[quoted text clipped - 5 lines]
>> >> >
>> >> > Thanks.

Signature
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.
Susie Johnson - 08 May 2007 02:05 GMT
I would reccomend using SQL Server and then you can use a custom datatype
and associate a RULE for it
and if that doesnt' work-- then you could use a trigger
Access doesn't allow for high-quality data
> Try replacing the Me.ActiveControl with the actual name of your control.
> Crystal gave you generic code and we should try specific code. You might
[quoted text clipped - 14 lines]
> >> >> >
> >> >> > Thanks.
ruralguy - 08 May 2007 02:22 GMT
I believe there is a slight price differential between Access and SQL Server.
>I would reccomend using SQL Server and then you can use a custom datatype
>and associate a RULE for it
[quoted text clipped - 8 lines]
>> >> >> >
>> >> >> > Thanks.

Signature
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.
Nick - 08 May 2007 06:58 GMT
Thanks! I did need to use the control name.
> Try replacing the Me.ActiveControl with the actual name of your control.
> Crystal gave you generic code and we should try specific code. You might
[quoted text clipped - 14 lines]
> >> >> >
> >> >> > Thanks.
ruralguy - 08 May 2007 11:34 GMT
Glad I could help Nick. Thanks for posting back with your success.
>Thanks! I did need to use the control name.
>
[quoted text clipped - 3 lines]
>> >> >> >
>> >> >> > Thanks.

Signature
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.