Results 1 to 5 of 5
  1. #1
    NickD is offline Novice
    Windows 11 Access 2016
    Join Date
    Feb 2025
    Posts
    3

    Append or Update? I can't figure it out

    I have a table of of data that contains the fields 'Email' address and 'Alternate Email' addresses that are imported into a table. I've then created a duplicated table of the original data. What i'm trying to do, is update or append the emails from the 'Alternate Email' field to the 'Email' field whereby there is a matching criteria in the 'Alternate Email' field Like "*John Doe*".

    For example, If record 250 in the 'Alternate Email' address field contained NickD@johndoe.co.uk, i want it to overwrite whats in the 'Email' field. If the 'Alternate Email' field is blank or doesn't contain 'John Doe', i want the update to skip to the next record.

    The example Query as an update Query, i get the 40 records i would expect to see from the 'Alternate Email' field, but they won't update in the correct 'Email' field.

    Any assistance on what i'm doing wrong wold be greatly appreciated....Do i need more Criteria rules or is my table selection incorrect as i've tried this multiple ways.
    Click image for larger version. 

Name:	Access Update or Append Screenshot.jpg 
Views:	26 
Size:	116.3 KB 
ID:	52667



    UPDATE UKG_People_Data_Feed_tbl_BAK INNER JOIN UKG_People_Data_Feed_tbl ON UKG_People_Data_Feed_tbl_BAK.[Employee Number] = UKG_People_Data_Feed_tbl.[Employee Number] SET UKG_People_Data_Feed_tbl.[Employee Number] = [UKG_People_Data_Feed_tbl_BAK].[Employee Number], UKG_People_Data_Feed_tbl.[First Name] = [UKG_People_Data_Feed_tbl_BAK].[First Name], UKG_People_Data_Feed_tbl.[Last Name] = [UKG_People_Data_Feed_tbl_BAK].[Last Name], UKG_People_Data_Feed_tbl.Username = [UKG_People_Data_Feed_tbl_BAK].[Username], UKG_People_Data_Feed_tbl.Country = [UKG_People_Data_Feed_tbl_BAK].[Country], UKG_People_Data_Feed_tbl.[Alternate Email] = [UKG_People_Data_Feed_tbl_BAK].[Email]
    WHERE (((UKG_People_Data_Feed_tbl.[Alternate Email]) Like "*johndoe*"));




  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Break it to down into small steps.
    First. you want an Update query.
    Get the correct data with a Select query.
    Then in the design view change it to an update query and set the required fields.

    However, moving data like that is not the norm for databases, unless you have made a huge mistake.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    your current SQL is updating from the BAK table?

    Code:
    UPDATE UKG_People_Data_Feed_tbl_BAK 
        INNER JOIN UKG_People_Data_Feed_tbl 
            ON UKG_People_Data_Feed_tbl_BAK.[Employee Number] = UKG_People_Data_Feed_tbl.[Employee Number] 
    SET UKG_People_Data_Feed_tbl.[Employee Number] = [UKG_People_Data_Feed_tbl_BAK].[Employee Number], 
    UKG_People_Data_Feed_tbl.[First Name] = [UKG_People_Data_Feed_tbl_BAK].[First Name], 
    UKG_People_Data_Feed_tbl.[Last Name] = [UKG_People_Data_Feed_tbl_BAK].[Last Name], 
    UKG_People_Data_Feed_tbl.Username = [UKG_People_Data_Feed_tbl_BAK].[Username], 
    UKG_People_Data_Feed_tbl.Country = [UKG_People_Data_Feed_tbl_BAK].[Country], 
    UKG_People_Data_Feed_tbl.[Alternate Email] = IIF(NZ(UKG_People_Data_Feed_tbl.[Alternate Email], "@~") LIKE "*johndoe*", [UKG_People_Data_Feed_tbl_BAK].[Email], UKG_People_Data_Feed_tbl.[Alternate Email])
    

  4. #4
    NickD is offline Novice
    Windows 11 Access 2016
    Join Date
    Feb 2025
    Posts
    3
    Click image for larger version. 

Name:	Email Update Requirement Example - Access Update or Append Screenshot.jpg 
Views:	25 
Size:	32.1 KB 
ID:	52669

    Hi Both, thanks for the swift response.

    I probably should have explained better, so apologies for that.

    In the current query, the 'Email' field where the value criteria "*johndoe*" is not present in the record field needs to be updated with the information in the 'Alternate Email' field.

    I need the 'Alternate Email' field where the value criteria "*johndoe*" is updating the 'Email' field like 'Employee Number' 500009.

    If the 'Alternate Email' doesn't contain the value criteria "*johndoe*", the update query skips to the next record containing "*johndoe*" to update.

    As per the example, i'm trying to update row 500007 to match row 500009 (I know this example would create a duplicate, but i can't share examples of the original data)

    Like i say, i can view the 40 records i need to move from 'Alternative Email' to 'Email', but can't get the query to update the correct field.

    I hope the example above helps.

  5. #5
    NickD is offline Novice
    Windows 11 Access 2016
    Join Date
    Feb 2025
    Posts
    3

    Append or Update? I can't figure it out

    Quote Originally Posted by Welshgasman View Post
    Break it to down into small steps.
    First. you want an Update query.
    Get the correct data with a Select query.
    Then in the design view change it to an update query and set the required fields.

    However, moving data like that is not the norm for databases, unless you have made a huge mistake.


    Hi Both, thanks for the swift response.

    I probably should have explained better, so apologies for that.

    In the current query, the 'Email' field where the value criteria "*johndoe*" is not present in the record field needs to be updated with the information in the 'Alternate Email' field.

    I need the 'Alternate Email' field where the value criteria "*johndoe*" is updating the 'Email' field like 'Employee Number' 500009.

    If the 'Alternate Email' doesn't contain the value criteria "*johndoe*", the update query skips to the next record containing "*johndoe*" to update.

    As per the example, i'm trying to update row 500007 to match row 500009 (I know this example would create a duplicate, but i can't share examples of the original data)

    Like i say, i can view the 40 records i need to move from 'Alternative Email' to 'Email', but can't get the query to update the correct field.

    I hope the example above helps.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-21-2011, 01:30 PM
  2. can't figure out what i'm doing wrong
    By m0use in forum Queries
    Replies: 4
    Last Post: 06-16-2011, 09:18 AM
  3. Replies: 5
    Last Post: 09-24-2010, 05:04 PM
  4. Easy question...so why can't I figure it out?
    By bdrago527 in forum Access
    Replies: 1
    Last Post: 10-02-2008, 02:40 PM
  5. Can't Figure It Out!!
    By jdohio5 in forum Database Design
    Replies: 1
    Last Post: 05-04-2006, 06:49 AM

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