Results 1 to 6 of 6
  1. #1
    steenesse is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    11

    Disregard error when importing

    Hi

    I have created a VBA script that imports an XML files from any subfolder in a specific folder and it works fine the first time, but I need it to continuosly scan that folder for new entries and not import the old, so I made one field an primary key. That works, but means that I get 31550 error when trying to import new files which stops the import. Is there any way I can make the importer ignore that error and just import what CAN be imported ?

    Best regards



    Steen

  2. #2
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    What is the VBA being used ? Difficult to assist without seeing how you are doing it...
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    steenesse is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    11
    Quote Originally Posted by Minty View Post
    What is the VBA being used ? Difficult to assist without seeing how you are doing it...
    Sorry. Here it is:



    Sub XMLImport()
    Dim fs
    Dim fsFolder
    Dim fsFile


    Set fs = CreateObject("scripting.filesystemobject")
    Set fsFolder = fs.GetFolder("C:\imagineorders")


    For Each SubFolder In fsFolder.Subfolders
    For Each fsFile In fsFolder.Files
    Debug.Print fsFile.Name
    Application.ImportXML (SubFolder) & "/" & fsFile.Name, acAppendData

    Next fsFile
    Next SubFolder
    End Sub

  4. #4
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    The only way to handle this really is to import the XML to a temp table, then run an append query to only import the new records.

    The 31550 error is doing the correct thing and telling you about duplicate records, it shouldn't really be ignored per se.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    steenesse is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    11
    Hi

    Thanks for replying. Found the On Error Resume Next statement and it seems to do the trick.

  6. #6
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    The problem with that approach is that you will now ignore any and all errors raised that part of your code.

    Either filter your error handler for that specific error code, or better still avoid raising the error by using the temp table to only import the correct information.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Error when Importing from a .mdb to a .accdb
    By Naomi Manickam in forum Access
    Replies: 1
    Last Post: 08-19-2013, 11:35 AM
  2. Error when importing text file
    By narendrabr in forum Import/Export Data
    Replies: 1
    Last Post: 01-11-2013, 03:27 AM
  3. Importing objects error
    By Abacus1234 in forum Import/Export Data
    Replies: 8
    Last Post: 06-15-2012, 10:31 AM
  4. Error Importing Specifications
    By x0200196 in forum Access
    Replies: 3
    Last Post: 06-08-2011, 09:09 AM
  5. Error message when importing
    By ljenkins23 in forum Access
    Replies: 5
    Last Post: 06-10-2010, 09:30 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