Query problem

endri81

Registered User.
Local time
Today, 08:03
Joined
Jul 5, 2010
Messages
121
Hi.
I don't know what's wrong with this query

GrupMosha: (IIf(([Mosha]<=19),"14-19 vjec",
IIf(([Mosha]<=24),"20-24 vjec",IIf(([Mosha]<=29),"25-29 vjec",IIf(([Mosha]<=34),"30-34 vjec",IIf(([Mosha]>34),"Me shume se 34 vjec")))))))

but I cannot get data range 30-34 for birthday 1979.The other ranges work fine but form Mosha <=34 I get "Me shume se 34 vjec"

Please help
 
Put this inside a Module:

Code:
Public Function GetMosha(intMosha As Long) As String
    Select Case intMosha
        Case Is <= 19
            GetMosha = "14-19 vjec"
        Case Is <= 24
            GetMosha = "20-24 vjec"
        Case Is <= 29
            GetMosha = "25-29 vjec"
        Case Is <= 34
            GetMosha = "30-34 vjec"
        Case Is > 34
            GetMosha = "Me shume se 34 vjec"
        Case Else
            ' do nothing
    End Select
End Function

Use it in your query like this:
Code:
GrupMosha: GetMosha(Nz([Mosha], 0))
 
I've never seen an IIF with bracketting like this
GrupMosha: (IIf(([Mosha]<=19),"14-19 vjec",

normally it is
IIF([field]<=19,Truepart,Falsepart)

So
GrupMosha: (IIf([Mosha]<=19,"14-19 vjec",IIF(....


But you say that it all works except for one condition.


Brian
 
Good point Brian.

Unless he did something like:
GrupMosha: (IIf(([Mosha]<=19) = True,"14-19 vjec",

would it work correctly with the bracketting.
 

Users who are viewing this thread

Back
Top Bottom