If Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an event table with ID's 1-26

I'm using the following command in a query to print either Label 1 or Label 2
Type: IIf([EventID]<>4,"Label 1","Label 2")

I need to change this to be able to select additional Labels based on Event
ID's 3 and 22. This will add Label 3 for EventID 22 and Label 4 for EventID 3

I'm looking for recommendations on how to best approach this. Being new to
Access, I may be having difficulty with syntax so any details are appreciated.
 
IIF statements can be nested, in your example below replace the "Label 2"
with another IIF statement to include another comparison. Repeat this,
replace the "innermost" false option with another IIF statement as needed.

The best way to do this would be to create an event to label table, that way
any future changes would only require an entry or simple change in a table..
rather than digging through your queries.
 
Event to Label Table makes perfect sense. The approach will be to add a Label
field in the Event table and adjust as appropriate. Is that correct?

Lance said:
IIF statements can be nested, in your example below replace the "Label 2"
with another IIF statement to include another comparison. Repeat this,
replace the "innermost" false option with another IIF statement as needed.

The best way to do this would be to create an event to label table, that way
any future changes would only require an entry or simple change in a table..
rather than digging through your queries.

Zanstemic said:
I have an event table with ID's 1-26

I'm using the following command in a query to print either Label 1 or Label 2
Type: IIf([EventID]<>4,"Label 1","Label 2")

I need to change this to be able to select additional Labels based on Event
ID's 3 and 22. This will add Label 3 for EventID 22 and Label 4 for EventID 3

I'm looking for recommendations on how to best approach this. Being new to
Access, I may be having difficulty with syntax so any details are appreciated.
 
Yeah, that should do it.

Zanstemic said:
Event to Label Table makes perfect sense. The approach will be to add a Label
field in the Event table and adjust as appropriate. Is that correct?

Lance said:
IIF statements can be nested, in your example below replace the "Label 2"
with another IIF statement to include another comparison. Repeat this,
replace the "innermost" false option with another IIF statement as needed.

The best way to do this would be to create an event to label table, that way
any future changes would only require an entry or simple change in a table..
rather than digging through your queries.

Zanstemic said:
I have an event table with ID's 1-26

I'm using the following command in a query to print either Label 1 or Label 2
Type: IIf([EventID]<>4,"Label 1","Label 2")

I need to change this to be able to select additional Labels based on Event
ID's 3 and 22. This will add Label 3 for EventID 22 and Label 4 for EventID 3

I'm looking for recommendations on how to best approach this. Being new to
Access, I may be having difficulty with syntax so any details are appreciated.
 
Back
Top