Solved

Error on TransferText

Posted on 2003-11-19
3
652 Views
Last Modified: 2012-08-14
I am getting the following error when I try to use the TransferText method:
Method 'TransferText' of object 'DoCmd' failed.  

Does anyone know why I am getting this error??  My code is below....

    Dim strData As String
    Dim objACC As Access.Application

    Set objACC = New Access.Application
    strDB = gdb.Name
    gdb.Close
    objACC.OpenCurrentDatabase strDB

    If Len(Me.txtFileName) = 0 Then
        MsgBox "Text file spec not entered yet"
        Exit Sub
    ElseIf UCase(Right(Me.txtFileName, 4)) <> ".TXT" Then
        Me.txtFileName = Me.txtFileName & ".txt"
    End If
   
    Screen.MousePointer = vbHourglass
    If Me.optOutput(0).Value = True Then
        objACC.DoCmd.TransferText acExportDelim, CStr("Data Label Export"), CStr("LabelCIDSData"), CStr(Me.txtFileName.Text), True
    Else
        objACC.DoCmd.TransferText acExportDelim, "Formatted Label Spec", "LabelCIDSLabels", Me.txtFileName.Text, True
    End If
0
Comment
Question by:vb9666
  • 2
3 Comments
 
LVL 8

Expert Comment

by:ampapa
ID: 9782170
It could be some data in your file doesn't agree with your file spec. Have you tried manually importing your text file into Access?
0
 

Author Comment

by:vb9666
ID: 9787161
I am trying to export to the text file and use the TransferText method.  However, since it will not work, I do not have a text file that has been exported.  How do I look at the file spec??  I did not create it.

Thanks.
0
 
LVL 8

Accepted Solution

by:
ampapa earned 125 total points
ID: 9796251
Sorry, I thought you were importing into not out of Access I should have read more closely.

You can see the specs by going to View/Options and checking Hidden Objects and System Objects. They hide the filespecs for a reason so be careful but you might be able to get some clue as to what might be happening.

This is from the help file:
"SpecificationName  Optional Variant. A string expression that's the name of an import or export specification you've created and saved in the current database. For a fixed-width text file, you must either specify an argument or use a schema.ini file, which must be stored in the same folder as the imported, linked, or exported text file. To create a schema file, you can use the text import/export wizard to create the file. For delimited text files and Microsoft Word mail merge data files, you can leave this argument blank to select the default import/export specifications."

It appears that it should be using the default FileSpec? could be some other issue/installation problem?

Have you tried creating a filespec in order to do the import? Open access and Export your table to a Textfile, when the window opens click on "Advanced" that will allow you create and save a FileSpec. Then use that name when you try your export and see if that works. The filespec becomes a hidden Object and is also then associated with that DB.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now