How do I make sure the year entry is current year

How do I make sure the year entry is current year

Post by Tmlja » Tue, 08 May 2007 09:30:00


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
be incorrect. What could one do to the text box to make sure they year entry
in the OTDLdate text box is that of the current year? I do not need to have
current Date() as entry are not done daily.

Thanks.
 
 
 

How do I make sure the year entry is current year

Post by strive4pea » Tue, 08 May 2007 09:43:19

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
*

 
 
 

How do I make sure the year entry is current year

Post by Tmlja » Tue, 08 May 2007 22:28:00

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.
 
 
 

How do I make sure the year entry is current year

Post by ruralguy v » Tue, 08 May 2007 23:01:50

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?



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

Message posted via http://www.yqcomputer.com/
 
 
 

How do I make sure the year entry is current year

Post by Tmlja » Tue, 08 May 2007 23:37:00

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.
 
 
 

How do I make sure the year entry is current year

Post by ruralguy v » Wed, 09 May 2007 00:51:49

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.



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

Message posted via http://www.yqcomputer.com/
 
 
 

How do I make sure the year entry is current year

Post by Susie John » Wed, 09 May 2007 10:05:02

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






for
the
error?
that is
 
 
 

How do I make sure the year entry is current year

Post by ruralguy v » Wed, 09 May 2007 10:22:04

I believe there is a slight price differential between Access and SQL Server.



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

Message posted via http://www.yqcomputer.com/
 
 
 

How do I make sure the year entry is current year

Post by Tmlja » Wed, 09 May 2007 14:58:00

Thanks! I did need to use the control name.
 
 
 

How do I make sure the year entry is current year

Post by ruralguy v » Wed, 09 May 2007 19:34:06

Glad I could help Nick. Thanks for posting back with your success.



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

Message posted via AccessMonster.com
http://www.yqcomputer.com/