Update Query / Multiple criteria - MSAccess 2010

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • M0ji
    New Member
    • Jan 2013
    • 15

    Update Query / Multiple criteria - MSAccess 2010

    I have created an update query to auto populate the value of one field based on the value of another field.

    I have two fields "Level" and "Document"

    if Document is A, Level needs to be 1
    if Document is B, Level needs to be 2
    if Document is C, Level needs to be 3

    as far as I can see the GUI only lets you enter one criteria, but I am sure there is a way to avoid three different update queries and do it all in one, any suggestions?
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    You could use the Switch() function :
    Code:
    UPDATE [YourTable]
    SET    [Level]=Switch([Document]='A',1,[Document]='B',2,True,3)

    Comment

    • M0ji
      New Member
      • Jan 2013
      • 15

      #3
      It worked great
      Thanks

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Although since this field seems to be derived from the other field, you may not want to store it and calculate it as needed.

        Comment

        Working...