Results 1 to 3 of 3
  1. #1
    PicoTTS is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2016
    Posts
    29

    Update a Linked Excel Table

    Hi,

    I was wondering if there was a way to use Access to update values in an excel file?



    I connected a linked excel sheet and when I try to edit any data, I get a message that says "This RecordSet is not updateable". I was hoping to use an update query in access to update the values in my excel file.

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you cant update, but you can export via COPYFROMRECORDSET.
    or
    post directly to the cell by opening control of excel.

    Code:
    Private XL As Excel.Application
    
    
    Set XL = CreateObject("excel.application")
    with xl
      .Visible = true
      .workbooks.open vFile
      .Range("a1").value = "my new value"
    end with

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,431
    you can edit using a query rather than a linked table

    if your query is something like this

    Code:
    SELECT *
    FROM [sheet1$] AS xlData IN 'C:\pathtofile\myxlfilename.xlsx'[Excel 12.0;HDR=yes;IMEX=0;ACCDB=Yes]
    Note the IMEX setting must be 0 which puts the query into export mode. (IMEX=1 is import mode, IMEX=2 is linked mode) - import and linked modes are not editable.

    You can even have the excel file open at the same time (open it before you open the query otherwise it will open readonly) - edits in the query are immediately visible in the excel file, edits in the excel file are visible in the query when it receives back the focus. I've only tested this with me opening both - don't know if it will work if someone else has the file open or multiple access users are trying to edit the same excel file at the same time.

    I tend not to use linked tables any more (in relation to excel, csv and other access files) using queries like the above built in vba as required and often linked to other tables (for example using left joins to importing only new data)

    Note that using sheet1$ only brings through the populated columns and rows (i.e. the end|home range), you can specify ranges and range names if required

    edit: if you want to append, you need to save the above query (call it say qryXL), then you can use it in an append query

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

Similar Threads

  1. Replies: 5
    Last Post: 09-13-2017, 07:42 AM
  2. Replies: 3
    Last Post: 04-07-2016, 04:36 AM
  3. Replies: 3
    Last Post: 12-17-2015, 07:01 AM
  4. Replies: 1
    Last Post: 07-13-2015, 02:47 AM
  5. Replies: 1
    Last Post: 01-22-2011, 12:23 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