• Update odd # to A and even # to B (2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Update odd # to A and even # to B (2000)

    Author
    Topic
    #369341

    I have a database that has over 17,000 records in it. Because of the way the data was received I need to assign A to all of the odd numbers and B to all of the even number records. I know how to do Update queries. But I not sure how to write the criteria in this situation. Any ideas or help would be appreciated. Thank you. Fay

    Viewing 1 reply thread
    Author
    Replies
    • #581262

      First thing to do is backup your database!

      I’d do it in 2 passes. Use a selection criteria to select the odd or even values. This should return True for even numbers:

      ( CLng(someField/2) *2 = SomeField)

    • #581264

      A simpler way would be to use the Update Query. In the “Update To” section of the field you want the “A” or “B” …. use the following example:

      IIf([YourNumber] Mod 2=0,”B”,”A”)

      “YourNumber” should be the name of the field that contains the numbers to evaluate as Odd or Even.

      HTH
      RDH

      • #581265

        It worked like a champ. Thank you. Can you explain the code a little more. The Mod2=0,”B”,”A” part.

        Once again you guys come through again. Fay

        • #581267

          Mod 2 …. means divide the number by 2 and only return the remainder.

          So if you think about it …. any whole number that can be divided by 2 equally with no remainder is an “Even” number. The rest will be “Odd”.

          Hope this explains what the expression does.

          RDH

    Viewing 1 reply thread
    Reply To: Update odd # to A and even # to B (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: