Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with IIf as Textbox Control Source with date field

Status
Not open for further replies.

DaveWalker

Programmer
Dec 4, 2000
7
US
I have a Textbox control on a form and I am trying to use the following as the Control Source:

=IIf([MyDate]=#1/1/2000#,"Happy New Year",[MyDate])

The idea is to display some text if a date matches exactly, or the date in the field if it's not a match.

Two problems I'm running into are

=IIf([MyString]="foo","yes","no") works if MyString is a text field, but not if it's a date field. (I can't seem to hit on the correct format for "foo" for dates)

=IIf([MyString],[MyString],"empty") works fine if it's a text field, but again errors if it's a date field.

Thanks for any light you can shed....
 
I'm a little confused as to what is your question? Use the # symbol to signify dates, just as " signify strings You did this in your first example. Your third example needs a comparison as the first criteria, i.e.

=IIf([MyString]="somestring",[MyString],"empty")

if you are storing a date in a string field, you need to compare it as a string:

=IIf([MyString]="1/1/01","yes","no")

I'm not sure if I am helping, so could you please elaborate on what exactly it is that you are trying to do.






Mike Rohde
rohdem@marshallengines.com
 
I'm a little confused as to what your question is. Use the # symbol to signify dates, just as " signify strings. You did this in your first example. Your third example needs a comparison as the first criteria, i.e.

=IIf([MyString]="somestring",[MyString],"empty")

if you are storing a date in a string field, you need to compare it as a string:

=IIf([MyString]="1/1/01","yes","no")

I'm not sure if I am helping, so could you please elaborate on what exactly it is that you are trying to do.






Mike Rohde
rohdem@marshallengines.com
 
sorry about the double post.
Mike Rohde
rohdem@marshallengines.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top