I have a table containing the following fields:
Automatic ID
RealDate
Morning
Afternoon
I use the name “RealDate” as I originally had other forms of storing the date – now dispensed with. It is just a date.
“Morning” and “Afternoon” contain 1 to three names which may be of the form “Joe Smith & Fred Blogs” or Jane & John Smith so I cannot search for “Jane Smith”. I must search separately to see if both “Jane” and “Smith” are in the string.
I am trying to find the number of sessions that each person has volunteered.
So I tried inserting the text below in the SQL page of the query to find out how many times |Jane Smith has volunteered in the last year. Unfortunately it returns the error "missing operator".
As I have only been using (trying to use) SQL for a couple of days my ignorance is overwhelming and I am at a complete loss.
Where am I going wrong?
SELECT [Table Rota].ID
, [Table Rota].RealDate
, [Table Rota].Morning
, [Table Rota].Afternoon
, IIf((Like “*[Morning]*” = ”Jane” AND Like “*[Morning]*” = ”Smith” ) , Expr1=Expr1+1, Expr1=Expr1 )
, IIf((Like “*[Afternoon]*” = ”Jane” AND Like “*[Afternoon]*” = ”Smith” ) , Expr1=Expr1+1, Expr1=Expr1)
FROM [Table Rota]
WHERE ((([Table Rota].RealDate)>#8/31/2010# Or ([Table Rota].RealDate)<#9/1/2011#));
As far as I can find out the IIf functions has the form
IIF(Condition, value if true, value if false)
Like “*[Afternoon]*” = ”Jane” is one condition
Like “*[Afternoon]*” = ”Smith” is another condition joined by an AND
Expr1=Expr1+1 is the value if true
Expr1=Expr1 is the value if false (probably redundant and not needed)
Automatic ID
RealDate
Morning
Afternoon
I use the name “RealDate” as I originally had other forms of storing the date – now dispensed with. It is just a date.
“Morning” and “Afternoon” contain 1 to three names which may be of the form “Joe Smith & Fred Blogs” or Jane & John Smith so I cannot search for “Jane Smith”. I must search separately to see if both “Jane” and “Smith” are in the string.
I am trying to find the number of sessions that each person has volunteered.
So I tried inserting the text below in the SQL page of the query to find out how many times |Jane Smith has volunteered in the last year. Unfortunately it returns the error "missing operator".
As I have only been using (trying to use) SQL for a couple of days my ignorance is overwhelming and I am at a complete loss.
Where am I going wrong?
SELECT [Table Rota].ID
, [Table Rota].RealDate
, [Table Rota].Morning
, [Table Rota].Afternoon
, IIf((Like “*[Morning]*” = ”Jane” AND Like “*[Morning]*” = ”Smith” ) , Expr1=Expr1+1, Expr1=Expr1 )
, IIf((Like “*[Afternoon]*” = ”Jane” AND Like “*[Afternoon]*” = ”Smith” ) , Expr1=Expr1+1, Expr1=Expr1)
FROM [Table Rota]
WHERE ((([Table Rota].RealDate)>#8/31/2010# Or ([Table Rota].RealDate)<#9/1/2011#));
As far as I can find out the IIf functions has the form
IIF(Condition, value if true, value if false)
Like “*[Afternoon]*” = ”Jane” is one condition
Like “*[Afternoon]*” = ”Smith” is another condition joined by an AND
Expr1=Expr1+1 is the value if true
Expr1=Expr1 is the value if false (probably redundant and not needed)