Results 1 to 12 of 12
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Simple Export Not So Simple

    I am trying to do a simple export of a table but I keep getting this error message:



    Run-time error '3027':
    "Cannot update. Database or object is read-only."

    Code:
        Dim varExportSpec As String
        Dim varTableName As String
        Dim varFileName As String
        varExportSpec = "AAtblBankExport Export Specification"
        varTableName = "AAtblBankExport"
        varFileName = "C:\BankExport\" & varTableName
        DoCmd.TransferText acExportDelim, varExportSpec, varTableName, varFileName
        MsgBox "Export Successful.", vbOKOnly
    Nothing else is open in the DB, just the form that I use to export. I don't have any other files in the folder path I am using.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    where are you exporting to? excel? is it shared? does someone else have it open?

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Jge said he had no file in that folder. So he must have been export to a new file.

    Maybe the folder is read only?

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I created the folder myself. Not read only. It is exporting to a network drive, but I have exported to the same location multiple times using the excel format. Now that I'm trying to export using a .txt format it doesn't want to work...

  5. #5
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I have also gone through the steps manually. Used the export spec and it works fine. Exported it to the same exact path as in my code.

  6. #6
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    When I click on "Debug" and rest over the variables the acExportDelim = 2. Everything else equals the value I have assigned it. Should acExportDelim = 2? The SpecID is 6 in the MSysIMEXSpecs.

  7. #7
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Do worry about the acExportDelim, it is Access predefined constant as well as other acXXXX.

    I am not sure why there is error.

  8. #8
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    If I run the same bit of code, but use TransferSpreadsheet instead it works just fine....

  9. #9
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Incase you all were wondering...I came across the issue. When exporting a ".txt" file apparently you have to put the ".txt" extension on the end of the file name. When exporting to Excel you don't, Access puts the file extension on there for you. The code ran successfully as below:

    Code:
        Dim varExportSpec As String
        Dim varTableName As String
        Dim varFileName As String
        Dim varExportFile As String
        
        varExportSpec = "AAtblBankExport2 Export Specification"
        varTableName = "AAtblBankExport"
        varExportFile = varTableName & ".txt"
        varFileName = "C:\Export\" & varExportFile
        DoCmd.TransferText acExportFixed, varExportSpec, varTableName, varFileName
        MsgBox "Export Successful.", vbOKOnly

  10. #10
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    I was just getting ready to respond with adding in the extension to the filename variable when I read your last post.

  11. #11
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    hah, Thanks for the help! Sometimes it is the simplest little things....

  12. #12
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I put .xls in file name when using transferspreadsheet even it is not necessary.

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

Similar Threads

  1. need help with this simple query
    By dada in forum Programming
    Replies: 3
    Last Post: 08-20-2010, 07:08 AM
  2. This must be simple but.....
    By adi in forum Access
    Replies: 11
    Last Post: 07-30-2010, 06:12 AM
  3. Simple question?
    By roads.zx in forum Access
    Replies: 0
    Last Post: 10-15-2009, 04:56 PM
  4. Export a simple query result to an excel file
    By wop_nuno in forum Import/Export Data
    Replies: 1
    Last Post: 05-21-2009, 04:18 AM
  5. Help with a simple query
    By JohnnyO in forum Queries
    Replies: 1
    Last Post: 02-11-2009, 09:43 PM

Tags for this Thread

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