Results 1 to 4 of 4
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    update sql code check

    Hi



    My database is now working so I'm tidying it all up for my own satisfaction

    have a single table named deceased with two fields notes and notes_2

    some fields in notes_2 are in notes and some are not.

    The ones that are in both fields I'll have to check manually but the other ie the ones that are not I could update?

    I created this sql code

    Code:
    UPDATE tblDeceased SET tblDeceased.Notes = [tblDeceased]![notes_2]
    WHERE (([tblDeceased]![Notes] & ""=""));
    The idea is that if the field in notes is empty then update the field

    I'd also like to delete the field in notes_2 after the update but can't see how to do it.

    I do however have a niggle that my logic is wrong somehow

    will the update run record by record to do I have to specify that the record ids have to be the same or am I confusing myself?

    thanks

    Ian

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Your code seems to work fine for me. If it is not working for you, make sure that the Notes field really is blank and doesn't contain a space or some other character.

    To delete the Notes_2 field, simply have another Update Query that set the value of Notes_2 = "" if Notes and Notes_2 are equal.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'd expect this to work to set the second field:

    UPDATE tblDeceased SET tblDeceased.Notes = [tblDeceased]![notes_2], [tblDeceased]![notes_2] = Null
    WHERE...

    or setting to "".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    thanks both for the assist

    Ian

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

Similar Threads

  1. Replies: 2
    Last Post: 07-27-2015, 05:20 PM
  2. Check Box VBA code in a form
    By alirezamb in forum Access
    Replies: 3
    Last Post: 02-17-2015, 04:35 PM
  3. Replies: 5
    Last Post: 06-26-2014, 12:52 PM
  4. Replies: 4
    Last Post: 03-10-2014, 12:18 PM
  5. Replies: 2
    Last Post: 06-28-2013, 12:58 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