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

Using something like an If...Then in a query? 1

Status
Not open for further replies.

tubbers

Technical User
Jun 23, 2004
198
US
I have a query that whose results will eventually be exported to Excel.

Code:
SELECT Integration.*, 
Integration!NumberSamples/(Sequence!IntegratedPings*16) AS [% Proc], 
((Integration!VoltsRms)^2)*SelectAequip!Aequip AS SV,
SelectAequip.Aequip, 
Sequence.File, 
Sequence.StartTime, 
Sequence.EndTime
FROM SelectAequip, Integration INNER JOIN (Configuration INNER JOIN Sequence ON Configuration.TableIndex=Sequence.SeqID) ON Integration.AbsSeq=Sequence.AbsSeq;

One of the fields in the Integration table is called Density Type. It is either blank (null) or has a value of "Exclude".

As it stands, the query is correct but the SV value for any of the records with a DensityType of "Exclude" needs to be calculated as zero, regardless of the value of VoltsRms. Simply excluding those records will not work.

Is there a way to do this in a query or would I need to do something with VBA coding? It needs to be simple as this query will be imported into a selection of databases for analysis.
 
You can use the immediate if function IIf() in a query. For instance:
Success:IIf([You Have Success]=True, "Congratulations", "Come back")

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]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
Thank you for the suggestion. It worked really well for what I needed. I've never used the Iif function before so I've learned something new.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top