Re: calculated field
- From: "John Spencer (MVP)" <spencer4@xxxxxxxxxxx>
- Date: Fri, 19 Aug 2005 17:16:20 -0400
Switch(TestCondition,ValueToReturn,TestCondition,ValueToReturn, ...)
It steps through until the first TestCondition returns True and then returns the
associated ValueToReturn.
Try Opening up VBA and looking in that help as Switch is a VBA function.
neeraj wrote:
>
> It worked, thanks, whats the syntax of the switch field. I couldn't find ot
> in access help
>
> "John Spencer (MVP)" wrote:
>
> > You can use a nested IIF statement or a SWITCH statement
> >
> > NEWField: SWITCH(Field1=val1 and Field2=val2 and Field3=val3, Val1-val2,
> > Field1=val1 and Field2=val2 and Field3=val4, val1-val2/100,
> > Field1=val1 and Field2=val2 and Field3=val5, val5*val2)
> >
> > WIth your example, you could combine IIF and the Switch function to
> >
> > NewField: IIF(Field1=val1 and Field2=val2,
> > SWITCH(Field3=val3, Val1-val2,
> > Field3=val4, val1-val2/100,
> > Field3=val5, val5*val2),Null)
> >
> > You didn't say what you wanted if none of the criteria matched, so I assumed Null
> >
> > neeraj wrote:
> > >
> > > I am creating a new field say, NewField in a query which uses other fields.
> > > I want the logic to be like this:
> > > If Field1=val1 and Field2=val2 and Field3=val3 then NewField = val1-val2
> > > If Field1=val1 and Field2=val2 and Field3=val4 then New Field = val1-val2/100
> > > If Field1=val1 and Field2=val2 and Field3=val5 then New Field = val5*val2
> > > Basically, val1 and val2 dont change and Field 3 is like a case statement
> > > and depending upon the case value, the operation for calculation of NewField
> > > changes. How can I create this NewField in Access
> >
.
- References:
- calculated field
- From: neeraj
- Re: calculated field
- From: John Spencer (MVP)
- Re: calculated field
- From: neeraj
- calculated field
- Prev by Date: Re: Update query?
- Next by Date: Re: Multi-Level BOM (Bill of Materials)
- Previous by thread: Re: calculated field
- Next by thread: Time difference between dates
- Index(es):
Relevant Pages
|