MULTIPLE 'IF' statements

  • Thread starter Thread starter Luther
  • Start date Start date
L

Luther

With this statement:

SELECT VariableTable.SectionName,
VariableTable.VariableName,
IF VariableTable.SectionName = "ADS" THEN
VariableTable.TestField = "Adult"
ELSE IF VariableTable.SectionName = "CAU" THEN
VariableTable.TestField = "Child"
ELSE VariableTable.TestField = "N/A"
FROM VariableTable;

I get a "syntax error (missing operator) in query
expression". What am I doing wrong? Can somebody help,
please?
 
Hi Luther,

It appears that you are mixing your programming language and query
language syntax. Are you constructing your SQL statement in code, or is
this the actual language of the query in the SQL View window? I'm
assuming the latter, in which case the SQL should read:

SELECT VariableTable.SectionName,
VariableTable.VariableName,Iif([VariableTable].[SectionName]="ADS","Adult",
Iif([VariableTable].[SectionName]="CAU","Child","N/A")) AS TestField
FROM VariableTable;


hth,

LeAnne
 
Thank you so much...this worked great
-----Original Message-----
Hi Luther,

It appears that you are mixing your programming language and query
language syntax. Are you constructing your SQL statement in code, or is
this the actual language of the query in the SQL View window? I'm
assuming the latter, in which case the SQL should read:

SELECT VariableTable.SectionName,
VariableTable.VariableName,Iif([VariableTable]. [SectionName]="ADS","Adult",
Iif([VariableTable].[SectionName]="CAU","Child","N/A")) AS TestField
FROM VariableTable;


hth,

LeAnne

With this statement:

SELECT VariableTable.SectionName,
VariableTable.VariableName,
IF VariableTable.SectionName = "ADS" THEN
VariableTable.TestField = "Adult"
ELSE IF VariableTable.SectionName = "CAU" THEN
VariableTable.TestField = "Child"
ELSE VariableTable.TestField = "N/A"
FROM VariableTable;

I get a "syntax error (missing operator) in query
expression". What am I doing wrong? Can somebody help,
please?
.
 
You're welcome!

LeAnne
Thank you so much...this worked great
-----Original Message-----
Hi Luther,

It appears that you are mixing your programming language and query
language syntax. Are you constructing your SQL statement in code, or is
this the actual language of the query in the SQL View window? I'm
assuming the latter, in which case the SQL should read:

SELECT VariableTable.SectionName,
VariableTable.VariableName,Iif([VariableTable]. [SectionName]="ADS","Adult",
Iif([VariableTable].[SectionName]="CAU","Child","N/A")) AS TestField
FROM VariableTable;


hth,

LeAnne

With this statement:

SELECT VariableTable.SectionName,
VariableTable.VariableName,
IF VariableTable.SectionName = "ADS" THEN
VariableTable.TestField = "Adult"
ELSE IF VariableTable.SectionName = "CAU" THEN
VariableTable.TestField = "Child"
ELSE VariableTable.TestField = "N/A"
FROM VariableTable;

I get a "syntax error (missing operator) in query
expression". What am I doing wrong? Can somebody help,
please?
.
 
Back
Top