Results 1 to 4 of 4

Thread: copy records from access db into notepad

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    35

    copy records from access db into notepad

    Hi all,

    I have a table in access with one column with data inside. I want to copy all of the data in this column into notepad. Can anybody tell me how to do this?

    Many thanks

    Carlos

  2. #2
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: copy records from access db into notepad

    From an exe or with VBA within Acces?

    Either Way it would be handy to know the name of the table an the name of the field in the table.
    And in A VB exe the filename an path would help as well.
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    35

    Re: copy records from access db into notepad

    vba in access

  4. #4
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: copy records from access db into notepad

    Comments in the code.....

    Code:
    Option Compare Database
    Option Explicit
    
    Sub OutPutToNotePad()
    
    'Open a recordset to read the content of the table.
    
    Dim Rc As DAO.Recordset
    Dim FileNumber As Long
    Set Rc = CurrentDb.OpenRecordset("SELECT Tabel1.* FROM Tabel1", dbReadOnly, dbForwardOnly)
    
    'Open A textFile to store the content of your table (this file will be overwritten each time you run this
    FileNumber = FreeFile()
    Open "C:\Temp\AccessOutputFile.Txt" For Output As #FileNumber
    
    'Write all records
    Do While Not Rc.EOF
        Write #FileNumber, Rc.Fields(0)
        Rc.MoveNext
    Loop
    'close the file
    Close #FileNumber
    
    'open the file in Notepad
    Shell "Notepad 'C:\Temp\AccessOutputFile.Txt'"
    
    End Sub
    You need to alter the file and table name.
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another 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
  •  



Click Here to Expand Forum to Full Width