A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

If then else statements in sql



 
 
Thread Tools Display Modes
  #1  
Old January 23rd, 2006, 03:42 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default If then else statements in sql

I want my query to return a message based on the input received. How do I
make this statement return a message to the same column

( IIf(IsNull(projects.date_filled),'Not filled',' ') ) AS Message

I want to be able to return a different message if the projects.date_ filled
is not null.

Here is the complete code:

SELECT Projects.Project, Projects.Position, Projects.Date_Open,
Projects.Date_Filled, Projects.Recruiter,
nz(Int(Projects.Date_Filled-Projects.Date_Open),0) AS Time_to_Fill,
Workdays(Projects.Date_Open,nz(Projects.Date_Fille d,Date())) AS
No_Working_Days, ( IIf(IsNull(projects.date_filled),'Not filled',' ') ) AS
Message
FROM Projects;

Thanks,
Akilah

  #2  
Old January 23rd, 2006, 03:48 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default If then else statements in sql

You should be able to return text like this:

IIf([projects].[date_filled] Is Null, "Not filled", "Filled") AS Message

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Akilah" wrote in message
...
I want my query to return a message based on the input received. How do I
make this statement return a message to the same column

( IIf(IsNull(projects.date_filled),'Not filled',' ') ) AS Message

I want to be able to return a different message if the projects.date_
filled
is not null.

Here is the complete code:

SELECT Projects.Project, Projects.Position, Projects.Date_Open,
Projects.Date_Filled, Projects.Recruiter,
nz(Int(Projects.Date_Filled-Projects.Date_Open),0) AS Time_to_Fill,
Workdays(Projects.Date_Open,nz(Projects.Date_Fille d,Date())) AS
No_Working_Days, ( IIf(IsNull(projects.date_filled),'Not filled',' ') ) AS
Message
FROM Projects;

Thanks,
Akilah



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL statements bbdobuddy Using Forms 1 May 10th, 2005 01:31 AM
Code Not Working DS New Users 11 May 9th, 2005 10:55 PM
Checking for results of SQL statements without saving queries. Amir Running & Setting Up Queries 1 January 21st, 2005 10:05 AM
Access and SQL AHopper General Discussion 26 August 3rd, 2004 07:01 PM


All times are GMT +1. The time now is 02:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.