Results 1 to 6 of 6
  1. #1
    stingray is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    22

    How to fill in missing info in a table - imported Excel into a table, then?

    Hi,


    I am pretty new to Access, and Have not written SQL for so many years...used to use SQL Server. So maybe it is something simple. When I run the query, Access says, " Operation must use an updateable query."
    Does this mean there is an error in SQL?

    I copied Product table, and made ProductImport table. I deleted all existing data in it, and imported data from Excel. So these two tables have exact structure. (The number of rows is different.) In the original, 3 pieces of information are missing, and the imported table has them. I don't mind running the Update query 3 times, though I am interested in doing it in one shot.

    Here is the query:

    Update Product
    Set OuterCase = (
    Select OuterCase
    From ProductImport
    Where product.CustomerSKU = productImport.CustomerSKU
    )
    Where Exists (
    Select OuterCase
    From ProductImport
    Where product.CustomerSKU = productimport.customerSKU
    );

    At first, I did not think "Where Exists..." was necessary, but it does not work with or without it. What does it do anyway?
    Could you please enlighten me? It must be something really simple.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I would say that the reason is probably #5 here
    http://allenbrowne.com/ser-61.html
    The solution might be to create a query that returns what is required by the sub query and join that to the outer query. FWIW, Excel sheets are seldom suitable for Access work, and the right option might be to create a properly designed table(s) to accept the sheet data. Then link to the sheet from Access and use update/append or upsert query to copy sheet data into the Access tables. If you have not studied db normalization already, I'd strongly advise that you do that first.

    Alternatively, you can import into Access, but the sheet data will no longer be dynamic inside of Access. You'd still need to copy the un-normalized (?) sheet data into Access tables.
    Last edited by Micron; 02-21-2025 at 02:55 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    stingray is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    22
    OP here.
    I changed direction, and let Access do it for me. It gave me this query:

    UPDATE Product INNER JOIN ProductImport ON Product.CustomerSKU = ProductImport.CustomerSKU
    SET Product.OuterCase = [ProductImport]![OuterCase],
    Product.InnerCase = [ProductImport]![InnerCase],
    Product.RetailPrice = [ProductImport]![RetailPrice];

  5. #5
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    That's weird syntax. (Well, for me) Normally more like

    Code:
    UPDATE Product
    SET
    
    Product.OuterCase = [ProductImport]![OuterCase],
    Product.InnerCase = [ProductImport]![InnerCase],
    Product.RetailPrice = [ProductImport]![RetailPrice]
    WHERE Product.CustomerSKU = ProductImport.CustomerSKU;

  6. #6
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    In Access, you can do it in 2 (i think) ways.

    1. Using joins:
    Code:
    UPDATE Product 
    INNER JOIN ProductImport 
    ON Product.CustomerSKU =  productImport.CustomerSKU 
    SET Product.OuterCase = productImport.OuterCase,
    Product.InnerCase = ProductImport.InnerCase,
    Product.RetailPrice = ProductImport.RetailPrice;
    2. Using cross-join
    Code:
    UPDATE Product, productImport 
    SET Product.OuterCase = productImport.OuterCase 
    Product.InnerCase = ProductImport.InnerCase,
    Product.RetailPrice = ProductImport.RetailPrice 
    WHERE
    Product.CustomerSKU = productImport.CustomerSKU;

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

Similar Threads

  1. Replies: 12
    Last Post: 04-16-2020, 10:25 AM
  2. Replies: 4
    Last Post: 03-19-2015, 06:14 PM
  3. Replies: 6
    Last Post: 10-09-2014, 12:41 PM
  4. Imported File (Not enough info)
    By Emma35 in forum Import/Export Data
    Replies: 7
    Last Post: 03-19-2013, 11:46 PM
  5. Replies: 2
    Last Post: 11-14-2012, 08:32 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