Reputation: 51
I want to group in my report by value [Order] with exception: if value of [tmp] is equal to 1, they should be grouped together with extra header
I tried
=IIf([tmp]=1;1;[Order])
but it just gives an error "This expression is typed incorrectly ...", basically every expression in grouping with IIf function gives that error, works fine in other parts of access
when i just put
=[Order]
it's fine
Is it just me who don't understand something about how expressions or grouping in access works?
Upvotes: 0
Views: 868
Reputation: 3455
Use a UNION query:
SELECT Max(YourField) FROM YourTable WHERE Tmp <> 1 GROUP BY [Order]
UNION
SELECT Max(YourField) FROM YourTable WHERE Tmp = 1 GROUP BY Tmp
Use a sub query to create a 'GroupField' based on your condition:
SELECT Max(YourField)
FROM (SELECT *, IIf(Tmp = 1, 1, [Order]) As GroupField FROM YourTable) As SubQuery
GROUP BY GroupField
You can use the sub query as the record source of your report and then group on the 'virtual' field GroupField
:
SELECT *, IIf(Tmp = 1, 1, [Order]) As GroupField FROM YourTable
Max(YourField)
and YourTable
are just to get my test query running, because you didn't specify the rest of your query.
Upvotes: 1