Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Apr 2007
    Posts
    22

    Unanswered: export table to txt file

    Dear,

    How to export table to txt file?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what would the help system say if (say you were to select it, select the index tab and say type in the following words export file?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2007
    Posts
    22
    I mean how to make code in VBA?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    although I hate using macros it would probably be best to do that as a macro.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Apr 2007
    Posts
    22
    Can you show me the fucntion for it?

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    TransferText
    George
    Home | Blog

  7. #7
    Join Date
    Apr 2007
    Posts
    22
    this i sent code, but not run as well as good.When we need to transfer, we should be click listbox first.I need we transfer only click button.

    scripts:

    Private Sub Command12_Click()

    Recordset.MovePrevious
    If Recordset.BOF Then
    Recordset.MoveFirst
    End If
    End Sub

    Private Sub Command7_Click()
    Recordset.MoveNext
    If Recordset.EOF Then
    Recordset.MoveLast
    End If
    End Sub

    Private Sub Form_Load()
    For i = 1 To Recordset.Fields.Count - 1
    LstField.AddItem Recordset.Fields(i).Name
    Next i

    'Menampilkan Total Record
    lblTotalRecord.Caption = "Total Records : " & _
    Recordset.RecordCount
    lblTotalRecord.FontBold = True
    End Sub




    Private Sub LstField_BeforeUpdate(Cancel As Integer)

    End Sub

    Private Sub LstField_DblClick(Cancel As Integer)

    'Membuat konstan directory dan file infotxt
    ExportTXT = "E:\DATABASE\FTP\Info.txt"

    'Membuka file untuk menambah data pada file txt
    Open ExportTXT For Append As #1

    Recordset.MoveFirst
    Posisi = LstField.ListIndex + 1
    'Membuat garis
    Print #1, String$(40, "=")
    Print #1, Recordset.Fields(Posisi).Name _
    & " " & "Total Record : " _
    & Recordset.RecordCount
    Print #1, String$(40, "=")

    'mencetak nilai dari field ke field txt
    For i = 1 To Recordset.RecordCount
    Print #1, Recordset.Fields(Posisi).Value
    Recordset.MoveNext
    Next i

    'Menampilkan pesan sukses export txt
    MsgBox "Field " & _
    Recordset.Fields(Posisi).Name & _
    " telah sukses di Export ke " _
    & ExportTXT, vbInformation, "Sukses"
    Close #1
    Recordset.MoveFirst
    End Sub

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If you are sending all the data from a table into a text file, you do not need to use recordsets, just take a look in the help file at the TransferText command.
    George
    Home | Blog

  9. #9
    Join Date
    Apr 2007
    Posts
    22
    But I have debug see:

    DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "E:\DATABASE\FTP\Info.txt"


    Click image for larger version. 

Name:	error.gif 
Views:	34 
Size:	6.3 KB 
ID:	6978

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You have not created a custom specification called "Standard Output"
    Let's just not use it and see what happens:
    Code:
    DoCmd.TransferText acExportDelim, , "External Report", "E:\DATABASE\FTP\Info.txt"
    George
    Home | Blog

  11. #11
    Join Date
    Apr 2007
    Posts
    22
    still debug Click image for larger version. 

Name:	error1.gif 
Views:	45 
Size:	6.5 KB 
ID:	6979

  12. #12
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What is the name of the table you are trying to export?
    If it is "External Report" then try wrapping that in square parens.
    NOTE: For future reference - never use spaces in names of tables, queries, fields, etc. You should be using CamelBack notation (where you capitalise the first letter of each word) or underscores (_) as a replacement. As you can see, it causes some problems otherwise
    George
    Home | Blog

  13. #13
    Join Date
    Apr 2007
    Posts
    22

    Question

    table1 to export

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If your table is called "table1" why are you trying to export a table called "External Report"

    Think about it
    George
    Home | Blog

  15. #15
    Join Date
    Apr 2007
    Posts
    22
    I put table2 into External Report after I make table but nothing ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •