Results 1 to 2 of 2
  1. #1
    Fostertrident is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    32

    Macro opening referenced Excel table

    Hi



    I'm using the following Macro to import a table from an excel file maintained by another team.

    Code:
    Option Compare Database
    
    
    Private Sub Form_Load()
    
    
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE A.* FROM A;"
    DoCmd.TransferSpreadsheet acImport, , "A", "B", True, "TABLE1!"
    DoCmd.SetWarnings True
    End Sub
    This works brilliantly when I have no other excel files open. However, if I have any Excel file open (not referenced in the above Macro at all) then when I open access it attempts to open the referenced Excel file (called "B" in the above Macro)

    This anomaly also happened to me when trying to use a Linked table in a previous iteration of my database.

    Do you think this is a Access issue? An Excel issue? or a Windows 10 issue? If anyone has any pointers how to prevent this it would be greatly appreciated as :-

    1) it slows the macro down considerably (the referenced excel file is huge)
    2) it means if someone else tries to use the excel file or database the whole thing crashes
    3) I would like things to work the way they are intended.


    I look forward to hearing from you.
    Last edited by Fostertrident; 10-09-2019 at 09:57 AM. Reason: Adding Code tags

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    What you posted is VBA, not a macro. Macros in Access are very different. Macros in Excel are really VBA code.

    Don't need to reference fields in DELETE action because entire record is deleted.

    I tested TransferSpreadsheet with an Excel workbook open. The workbook being imported from does not open. Cannot replicate issue.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-27-2017, 11:59 AM
  2. Error Opening MS access table from Excel ADO
    By jjfaith in forum Import/Export Data
    Replies: 2
    Last Post: 08-29-2016, 02:32 PM
  3. Replies: 1
    Last Post: 04-12-2013, 06:11 AM
  4. Replies: 1
    Last Post: 08-19-2012, 09:55 PM
  5. Replies: 11
    Last Post: 06-13-2012, 08:14 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