Results 1 to 6 of 6
  1. #1
    TallSA is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    8

    update records if condition met!

    Hi All,

    I have the below table in my DB, I would like to be able to search if the the column Action = "Discard" then all the field in the Action for the same Number set to "Discard"



    Number RepeatNo Count Action
    C001 5 4
    C001 1
    C001 2
    C001 3 dis
    C001 4
    C001 6
    C001 2 2
    C002 1
    C002 2 not
    C002 3
    C002 4
    C002 5 dis
    C002 6
    C003 2 6
    C003 5 1
    C003 2 5
    C003 2 6
    C003 4 1
    C004 1 not
    C004 2 not
    C004 3 not
    C004 4 yes
    C004 5 yes
    C004 6
    C005 4 3
    C005 5 12 dis
    C005 4 3 yes
    C005 5 12
    C005 2 1
    C005 2 1
    C005 2 1 dis
    C006 1 1
    C006 4 3
    C006 1 1
    C006 4 3
    C006 1 1 dis
    C006 4 3


    Thanks in advance for your help.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    build query 1 (to get the list)
    Q1 = select distinct [Number] from table where [action] = 'Discard'


    then use query 1 to update records from query 2
    Q2 = update Q1 set [action] = 'Discard'

    or you may have to join Q1 to your table on [number] (in case Q2 above cant update records)

  3. #3
    TallSA is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    8
    Hi Ranman256,

    Thank you for your help.

    I couldn't update Q2, so I joined the Q1 o my table, but nothing happened.

    Regards,

  4. #4
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    So if one of the multiple C001 is action = dis you want to set all the C001 's to dis?

    Do a join query joining on Number and then an update to update the records of the table.

  5. #5
    TallSA is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    8
    Hi Nick404

    Yes, that what I want to do.

    Could you please provide me with query code.

    Regards,

  6. #6
    TallSA is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    8
    Hi Nick404 and Ranman256,

    Thank you for your help, it works fine now,

    Thanks again.

    Regards,

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 06-24-2015, 09:04 AM
  2. Condition Formatting at After Update event (TextBox)
    By excellenthelp in forum Programming
    Replies: 8
    Last Post: 06-20-2014, 02:54 PM
  3. Update with if condition
    By drunkenneo in forum Queries
    Replies: 1
    Last Post: 03-27-2014, 02:16 PM
  4. Replies: 3
    Last Post: 04-30-2013, 02:01 PM
  5. Update 2 fields based on where condition.
    By Confused in forum Access
    Replies: 2
    Last Post: 11-19-2009, 05:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums