Results 1 to 5 of 5
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    Changing export Spec breaks code

    I have some code that creates an export file. I have included the code below. As you can see i have an export spec called Q_ExportToFileSpec. I have added a field to the query q_ExportToFile but when I go into the export spec and update the spec by adding a new field i get the following error:



    Procedure Name:
    Step: Checking version compatibility
    Error Number: 3011
    Error Description: The Microsoft Access database engine could not find the object 'Exported-Files.csv'. Make sure the object exists and that you spell its name and the path name correctly. If 'Exported-Files.csv' is not a local object, check your network connection or contact the server administrator.




    Code:
    On Error GoTo SubERR
    
    DoCmd.SetWarnings False
    spath = Environ("USERPROFILE") & "\Desktop"
    DoCmd.TransferText acExportDelim, "Q_ExportToFileSpec", "q_ExportToFile", spath & "\Exported-Files.csv", True
    
    
    MsgBox "Selected records have been exported to your desktop.", vbOKOnly, "File Exported"
    
    
    DoCmd.OpenQuery "q_ArchiveRepairs"
    DoCmd.OpenQuery "q_DeleteArchived"
    DoCmd.SetWarnings True
    
    
    SubEXIT:
    On Error Resume Next
        If Not rs Is Nothing Then
            rs.Close
            Set rs = Nothing
        End If
        Exit Sub
        
    SubERR:
        ErrorHandler
        DoCmd.SetWarnings True
        If gTesting Then
            Stop
            Resume Next
        Else
            GoTo SubEXIT
        End If

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Are you sure spath is resolving correctly? (to a path that exists)
    are you sure the spec is called 'Q_ExportToFileSpec'? , since its not a query, why would it start with 'Q_'?

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Tho now I seem to remember getting an error like this EVEN when the path was correct, and the query and spec was correct.
    The problem was, the .CSV extension. Access did not like it. When I used .TXT , it worked.

    IT MADE NO SENSE!!

  4. #4
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Well, the path does exist, the spec is correct (developer originally developed with that name, I don't know why). It actually works fine if I dont have the added field in the export spec. It will export the file and it will just not show the last field (netcharge) which is in the query.

    I tried to change it to .txt and that did not work either and I get the same message except it now says it cant find the object Exported-Files.TXT

    I also tried changing the spath variable to be a static path like D:\ExportFiles

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It sounds like the export spec did not get updated.

    Changing an import/export spec is a pain in the neck (only about 2.5 feet lower for me).
    I had to change an import spec due to field changes.
    I had to edit the spec, write down ALL of the settings, delete the spec, then add the settings and save with the same name.

    It can be done, it just takes perseverance.

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

Similar Threads

  1. Replies: 13
    Last Post: 01-25-2016, 01:36 PM
  2. Replies: 1
    Last Post: 08-05-2015, 10:36 AM
  3. Replies: 4
    Last Post: 06-04-2014, 01:25 PM
  4. Object not found when using export spec
    By ctlogistics in forum Import/Export Data
    Replies: 2
    Last Post: 05-07-2014, 10:38 AM
  5. Export Spec Type
    By bcn1988 in forum Programming
    Replies: 1
    Last Post: 12-13-2012, 09:05 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