If/Then Statement in a Query

Zippyfrog

Registered User.
Local time
Today, 06:11
Joined
Jun 24, 2003
Messages
103
Hi - I am creating a database that tracks all of the statistics for our track and field team. I am running into one issue though. In a field that I call "Final Result", I am having a running event automatically created calling the following:

[FinalTimeMinutes] & ":" & Format([FinalTimeSeconds],"00.00"

This works great for running events, but then for field events, it is put into the final time format.

Is there a way that I can use an if/then statement so that I have two different formats based off of a second field? I have a yes/no box in the query (which is the FieldEvent field), and if the box is checked, then it is a jumping event which needs to be measured in feet and inches. Can I create something like:

FinalResult: if(FieldEvent = True, [FinalTimeMinutes] & "-" & [FinalTimeSeconds], [FinalTimeMinutes] & ":" & Format([FinalTimeSeconds],"00.00")

This code doesn't work, but I know if I were in Excel, I would setup an If/Then statement something like this. How can I do this in the Access query? Thanks in advance.
 
Use the Immediate If in your query. IIF(<condition>, IfTrue, IfFalse)
 
Thanks - that did exactly what I wanted it to do.
 

Users who are viewing this thread

Back
Top Bottom