Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Problem with IIf in a SELECT statement for a Form.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Russell Pascoe - 23 Mar 2008 18:20 GMT
Hi!

I am trying to influence the outcome of a subform through the use of a Combo
Box in te form, and the following statement;

SELECT Tenants.* FROM Tenants WHERE (((Tenants.[Moved
Out])=IIf([Period]="Current",Tenants.[Moved Out] Is Null,Tenants.[Moved
Out])));

This is not producing the result I want. In essence it the combo bos has two
states, "All" and "Current", so I figured that the IIf statement would yield
the required filter. If the combo box ("Period") = "Current" then the tenants
will not have moved out, so [Moved Out] Is Null etc

When I run this, I get NO results for "Current" and I get all the records
EXCEPT the current tenants when I select "All"

I know the problem lies with my Iif statement, but I can't see what I have
done wrong. Your observations will be gratefully received!

Thanks
Russell.
Douglas J. Steele - 23 Mar 2008 18:43 GMT
You're trying to change the Tenants.[Moved Out]=something to Tenants.[Moved
Out] Is Null via an IIf statement. You can't do that.

Try:

SELECT Tenants.* FROM Tenants
WHERE ([Period]="Current" AND [Moved Out] Is Null)
OR ([Period] <> "Current")

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hi!
>
[quoted text clipped - 22 lines]
> Thanks
> Russell.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.