Conditional text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to have a text box that shows the starting date of employees who were
hired since 2001, but only "Before 2001" for those who came earlier.

I have used this in the control sourse of the form but it keeps coming up
with #Error

=IIf(DateDiff("yyyy",1/1/2001,[StartDate]),"Before
2001",Format([StartDate],"d mm yyyy"))

Where am I going wrong? Thanks for any help.

Sandy
 
Sandy,

Try something like:

IIf(Year([Startdate])<2001, "Before 2001", Format([StartDate],"d mm yyyy"))

HTH,
Nikos
 
Thanks to both of you. The function works and I had forgotten to add 'txt' to
the name of my textbox, which was the same as the field.
Sandy

Duane Hookom said:
Also, make sure the name of the text box is not the same as the name of a
field.

--
Duane Hookom
MS Access MVP
--

Nikos Yannacopoulos said:
Sandy,

Try something like:

IIf(Year([Startdate])<2001, "Before 2001", Format([StartDate],"d mm
yyyy"))

HTH,
Nikos
 
Back
Top