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

IF THEN With a string in a query

Status
Not open for further replies.

herschelrj

Programmer
Jan 12, 2005
24
0
0
US
I am trying to do the following. I created a query that gives me a count of employees and grouped by a registration date for training. I would like to display "Session Full" if the count is greater than 95. I tried to use an IF THEN statement in the criteria but keep getting a syntax error. Can anyone help?

herschelrj
 
Do you mind sharing your current SQL view? How about giving us some information regarding your table structure?

Placing something in the criteria might limit the displayed records to only classes full or not full. Is this what you want?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Here is the SQL.
SELECT LT9_FEB2005.crs_dt, Count(LT9_FEB2005.ID) AS CountOfID
FROM LT9_FEB2005
GROUP BY LT9_FEB2005.crs_dt;

I am looking for something like:

If CountOfID > 95 THEN "Course is Full"
 
How about creating another query based on this query:
SELECT Crs_Dt, CountOfID, IIf(CountOfID>95,"Course Is Full", "Still Openings") as Status
FROM qtotYourTotals;

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
You need to use iif() (immediate if) in queries....
 
Thanks to both of you. I got it to work with your help. Now I know I have to use the imediate if with queries. Again, thanks a million...

herschelrj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top