The query you gave in the answer Consolidate data on multiple rows into one (01 August 2003) is not working in MS Access 2002. Can you please tell me why?
Requires Free Membership to View
There are three differences in syntax that need to be made so that you can run the query in MS Access.
First, the CASE constructions must be rewritten with IIF functions:
select Name
, IIF(Food='Fruit','Fruit','') as Fruit
, IIF(Food='Banana','Banana','') as Banana
, IIF(Food='Bread','Bread','') as Bread
, IIF(Food='Pizza','Pizza','') as Pizza
from yourtable
Next, MS Access does not support derived tables. Well, it didn't in earlier versions, and I have not tested Access 2002, but in any case, there's a workaround. Just save the above query as query ZZZ (or some other name), and then you can use it in the FROM clause.
Finally, concatenation in Access is different, and uses the ampersand. (Access 97 gives the error message "Invalid use of vertical bars" which always struck me as hilarious. I mean, if it's smart enough to recognize them as vertical bars, why doesn't it just do the concatenation? The double vertical bars or pipes are the standard SQL concatenation operator.)
So the query becomes:
select Name
, max(Fruit)
& ' ' & max(Banana)
& ' ' & max(Bread)
& ' ' & max(Pizza) as Food
from ZZZ
group by Name
This was first published in September 2003

Join the conversationComment
Share
Comments
Results
Contribute to the conversation