Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

How do I check 2 variables with IIF (if/and)

Discussion in 'Information Technology' started by DSharbaugh, Jul 28, 2006.

  1. DSharbaugh

    DSharbaugh
    Expand Collapse
    Guest

    I need to evaluate two variables for truth in order to assign a calculated
    value in a Access query. (example: If a=true and b=true, value is x,
    otherwise is y.). This is the same thing you would do in Excel using an
    "if(and(..." formula. How is this done in Access?
     
  2. Loading...


  3. default105

    default105
    Expand Collapse
    Guest

    the IIf(expr,true,false) is fairly easy to use but as with any thing you must
    be careful with your format. This is a start for you
    IIf(expr1 And expr2= z, x, y)

    "DSharbaugh" wrote:

    > I need to evaluate two variables for truth in order to assign a calculated
    > value in a Access query. (example: If a=true and b=true, value is x,
    > otherwise is y.). This is the same thing you would do in Excel using an
    > "if(and(..." formula. How is this done in Access?
     
  4. PC Datasheet

    PC Datasheet
    Expand Collapse
    Guest

    Note that the expression suggested checks if expr1 is true and expr2 = z.
    The syntax of the expression is incorrect if your intent is to check if
    expr1 = z. If that is your intent, the correct expression is:
    IIf(expr1 = z And expr2= z, x, y)

    --
    PC Datasheet
    Your Resource For Help With Access, Excel And Word Applications
    Over 1175 users have come to me from the newsgroups requesting help
    resource@pcdatasheet.com




    "default105" <default105@discussions.microsoft.com> wrote in message
    news:DF586AFF-08B5-4DF9-9F04-092794169E9B@microsoft.com...
    > the IIf(expr,true,false) is fairly easy to use but as with any thing you
    > must
    > be careful with your format. This is a start for you
    > IIf(expr1 And expr2= z, x, y)
    >
    > "DSharbaugh" wrote:
    >
    >> I need to evaluate two variables for truth in order to assign a
    >> calculated
    >> value in a Access query. (example: If a=true and b=true, value is x,
    >> otherwise is y.). This is the same thing you would do in Excel using an
    >> "if(and(..." formula. How is this done in Access?
     
  5. default105

    default105
    Expand Collapse
    Guest

    PC is correct, sorry for the mistype DSharbaugh.

    "PC Datasheet" wrote:

    > Note that the expression suggested checks if expr1 is true and expr2 = z.
    > The syntax of the expression is incorrect if your intent is to check if
    > expr1 = z. If that is your intent, the correct expression is:
    > IIf(expr1 = z And expr2= z, x, y)
    >
    > --
    > PC Datasheet
    > Your Resource For Help With Access, Excel And Word Applications
    > Over 1175 users have come to me from the newsgroups requesting help
    > resource@pcdatasheet.com
    >
    >
    >
    >
    > "default105" <default105@discussions.microsoft.com> wrote in message
    > news:DF586AFF-08B5-4DF9-9F04-092794169E9B@microsoft.com...
    > > the IIf(expr,true,false) is fairly easy to use but as with any thing you
    > > must
    > > be careful with your format. This is a start for you
    > > IIf(expr1 And expr2= z, x, y)
    > >
    > > "DSharbaugh" wrote:
    > >
    > >> I need to evaluate two variables for truth in order to assign a
    > >> calculated
    > >> value in a Access query. (example: If a=true and b=true, value is x,
    > >> otherwise is y.). This is the same thing you would do in Excel using an
    > >> "if(and(..." formula. How is this done in Access?

    >
    >
    >
     
  6. DSharbaugh

    DSharbaugh
    Expand Collapse
    Guest

    This works great, thanks to both of you. However, now I have a new problem.
    I am unable to format my calculated fields as numbers in order to add them.
    They are being concatenated instead of added. Their are no format choices
    when I click on "properties" for that column of the query, however, even if I
    specify "#" as the format, the column meant to total 4 separate values is
    simply concatenating them. Any more advice available???

    Thanks,
    DLS

    "default105" wrote:

    > PC is correct, sorry for the mistype DSharbaugh.
    >
    > "PC Datasheet" wrote:
    >
    > > Note that the expression suggested checks if expr1 is true and expr2 = z.
    > > The syntax of the expression is incorrect if your intent is to check if
    > > expr1 = z. If that is your intent, the correct expression is:
    > > IIf(expr1 = z And expr2= z, x, y)
    > >
    > > --
    > > PC Datasheet
    > > Your Resource For Help With Access, Excel And Word Applications
    > > Over 1175 users have come to me from the newsgroups requesting help
    > > resource@pcdatasheet.com
    > >
    > >
    > >
    > >
    > > "default105" <default105@discussions.microsoft.com> wrote in message
    > > news:DF586AFF-08B5-4DF9-9F04-092794169E9B@microsoft.com...
    > > > the IIf(expr,true,false) is fairly easy to use but as with any thing you
    > > > must
    > > > be careful with your format. This is a start for you
    > > > IIf(expr1 And expr2= z, x, y)
    > > >
    > > > "DSharbaugh" wrote:
    > > >
    > > >> I need to evaluate two variables for truth in order to assign a
    > > >> calculated
    > > >> value in a Access query. (example: If a=true and b=true, value is x,
    > > >> otherwise is y.). This is the same thing you would do in Excel using an
    > > >> "if(and(..." formula. How is this done in Access?

    > >
    > >
    > >
     
  7. StopThisAdvertising

    StopThisAdvertising
    Expand Collapse
    Guest

    "PC Datasheet" <NoSpam@Spam.Com> schreef in bericht news:psuag.3222$y4.562@newsread2.news.pas.earthlink.net...

    --
    --
    > PC Datasheet
    > Your Resource For Help With Access, Excel And Word Applications 'Resource ????
    > Over 1175 users have come to me from the newsgroups requesting help '1175 users ????
    > resource@pcdatasheet.com


    --
    To Steve:
    No-one wants your advertising/job hunting here!
    Over 875 !! users from the newsgroups have visited the website to read what kind of a 'resource' you are... (rapidly increasing..)

    To the original poster:
    Most people here have a common belief that the newsgroups are for *free exchange of information*.
    But Steve is a notorious job hunter in these groups, always trying to sell his services.
    And he is known here as a shameless liar with no ethics at all.

    Before you intend to do business with him look at:
    http://home.tiscali.nl/arracom/whoissteve.html

    Arno R
     
  8. DSharbaugh

    DSharbaugh
    Expand Collapse
    Guest

    Never mind- I found my answer on another most helpful post of Allen Browne's.
    All is good now and I am quite pleased with the results. Having access to
    this forum is great!

    Thanks,

    DLS

    "DSharbaugh" wrote:

    > This works great, thanks to both of you. However, now I have a new problem.
    > I am unable to format my calculated fields as numbers in order to add them.
    > They are being concatenated instead of added. Their are no format choices
    > when I click on "properties" for that column of the query, however, even if I
    > specify "#" as the format, the column meant to total 4 separate values is
    > simply concatenating them. Any more advice available???
    >
    > Thanks,
    > DLS
    >
    > "default105" wrote:
    >
    > > PC is correct, sorry for the mistype DSharbaugh.
    > >
    > > "PC Datasheet" wrote:
    > >
    > > > Note that the expression suggested checks if expr1 is true and expr2 = z.
    > > > The syntax of the expression is incorrect if your intent is to check if
    > > > expr1 = z. If that is your intent, the correct expression is:
    > > > IIf(expr1 = z And expr2= z, x, y)
    > > >
    > > > --
    > > > PC Datasheet
    > > > Your Resource For Help With Access, Excel And Word Applications
    > > > Over 1175 users have come to me from the newsgroups requesting help
    > > > resource@pcdatasheet.com
    > > >
    > > >
    > > >
    > > >
    > > > "default105" <default105@discussions.microsoft.com> wrote in message
    > > > news:DF586AFF-08B5-4DF9-9F04-092794169E9B@microsoft.com...
    > > > > the IIf(expr,true,false) is fairly easy to use but as with any thing you
    > > > > must
    > > > > be careful with your format. This is a start for you
    > > > > IIf(expr1 And expr2= z, x, y)
    > > > >
    > > > > "DSharbaugh" wrote:
    > > > >
    > > > >> I need to evaluate two variables for truth in order to assign a
    > > > >> calculated
    > > > >> value in a Access query. (example: If a=true and b=true, value is x,
    > > > >> otherwise is y.). This is the same thing you would do in Excel using an
    > > > >> "if(and(..." formula. How is this done in Access?
    > > >
    > > >
    > > >
     

Share This Page