Using switch functions in expressions.

mech55

Registered User.
Local time
Today, 02:10
Joined
Aug 26, 2005
Messages
61
i'm trying to use a switch function in a query but i'm unfamiliar with the format a bit. here is what i'm trying to do...

switch([Radios]![Warranty] and [Radios]![HousingWarranty]=true,[Radios]![Change front housing]*(25/60*28), [[Radios]![Warranty] And [Radios]![PortableHousingWarranty]=true], [Radios]![MaterialsUsedPrice1])

basically first statement is condition second is execution. I need to add more but i'm getting an error from this much...if I was doing this in vb.net I would just do if, ifelse, ifelse, ifelse...but...

Thanks,
 
Hmmm, if you have more than just a couple of items that you want to change or "highlight" in a query. Have you thought of using a function to do the job and call it in the query? That way you could add as many items you like.

Just a thought.

EXAMPLE:
Code:
Function GetTheType(AnimalName As String) As String
   
    
    If AnimalName = "Cat" Then
        GetTheType = "Feline"
    Else
        GetTheType = "Don't Know"
    End If
    
End Function

Don't forget some error catching.
Hope this helps :)
 
I think that you need to be explicit with the '= true'

switch([Radios]![Warranty] = true and [Radios]![HousingWarranty]=true,[Radios]![Change front housing]*(25/60*28), [Radios]![Warranty] = true And [Radios]![PortableHousingWarranty]=true, [Radios]![MaterialsUsedPrice1])

Also the '[]'s in help indicate that it is optional :)

Peter
 

Users who are viewing this thread

Back
Top Bottom