Results 1 to 3 of 3
  1. #1
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    17

    Excel VBA: possible to create new records in an already-open access db?

    I have written (actually pirated, lol) some code that works very nicely to create new Access table records from Excel sheet, as long as the Accdb is closed. Else I get a "file already in use" error.


    Can i update the table using a different methodology?

    Do i just need to split the db? (so that the Excel vba can write to the "back end" file?)

    fwiw, here's my existing code:
    Code:
        'Open the connection.
        con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & accessFile
    
        'Create the SQL statement to retrieve the data
        sql = "SELECT * FROM " & accessTable
    
        'Create the ADODB recordset object.
        Set rs = CreateObject("ADODB.Recordset")
           
        'Set the necessary recordset properties.
        rs.CursorType = 1   'adOpenKeyset on early binding
        rs.LockType = 3     'adLockOptimistic on early binding
        
        'Open the recordset.
        rs.Open sql, con

  2. #2
    i-Zapp is offline Novice
    Windows 11 Office 365
    Join Date
    Jan 2024
    Posts
    17
    never mind!
    i answered my own question: needed to split the database and edit the "be" (back end) file, which is just the table.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Please mark it solved then.
    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

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

Similar Threads

  1. Button to create/open or copy/open an excel file
    By petrikos in forum Programming
    Replies: 23
    Last Post: 10-15-2021, 07:00 AM
  2. Access to open Excel and delete records, VBA
    By Lifeseeker1019 in forum Programming
    Replies: 2
    Last Post: 06-25-2020, 12:13 PM
  3. Replies: 3
    Last Post: 04-07-2016, 04:36 AM
  4. Replies: 2
    Last Post: 04-06-2015, 12:08 PM
  5. Open Excel from within Access?
    By kjw in forum Access
    Replies: 2
    Last Post: 04-08-2008, 07:12 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