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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement

Status
Not open for further replies.

nike2000

Technical User
Apr 1, 2003
61
GB
Hi,
I am looking to display on a form in an individual field those records that are after a certain date. The date is 01/01/2000, there are records prior and after this date.

I have composed the below If Statement but it isn't working!!!
[Trade date] is the other date field on the form that I am working with.

=IIf(([Trade Date]>(1/1/2000)),"No","Yes")

Can someone tell me where I have gone wrong?
Thanks
 
Are you getting an error or are you getting inaccurate data? If you're getting an error, try moving the if statement into your query:

NewFieldName:IIf(([Trade Date]>(1/1/2000)),"No","Yes")

and then setting the control source for the field to NewFieldName
 
Try putting hash marks around the date so Access knows it is a date - as shown below.

=IIf(([Trade Date]>(#1/1/2000#)),"No","Yes")
 
Something that I found with Access2002 (XP) is that in reports/forms, say you have a textbox Name: "Trade Date", then in the Control Source you have the formula:
=IIf(([Trade Date]>(1/1/2000)),"No","Yes")

it would return an #Error message.

The reason, is that the name is "Trade Date". in the formula, you are referencing that. so as an example:
IIF(a < 10, make a 20) basically, it's a loop.

Try renaming the &quot;Name&quot; to say &quot;Trade Date_Item&quot;

Hope it helps ;)
Aubs
 
Thanks for your help.
Problem now resolved.
Thanks
Nike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top