Results 1 to 3 of 3

Thread: Database to txt file

  1. #1

    Thread Starter
    Hyperactive Member JXDOS's Avatar
    Join Date
    Aug 2006
    Location
    Mars...
    Posts
    423

    Database to txt file

    Hi all,
    Is there a simple way to list all fields form a table which has 200,000 records into a text file(*.txt) in the format:

    field1 , field2, field3,.. etc

    *I am currently using MS Access for this.
    If my post has been helpful, please rate it!

  2. #2

  3. #3
    Hyperactive Member Foxer's Avatar
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    278

    Re: Database to txt file

    You want the field names or the data?

    For field names, I wrote this last week.

    Code:
    Function ListFields(strTableName As String) As String
    'Cycles through the field definition for the provided table and outputs the fields to a string
    
    Dim db As dao.Database
    Dim tb As dao.TableDef
    Dim fld As dao.Field
    
       Set db = OpenDatabase(gstrDBPath)
       Set tb = db.TableDefs(strTableName)
    
       For Each fld In tb.Fields
          ListFields = ListFields & fld.Name & " Type="
          Select Case fld.Type
             Case dbInteger 'Integer
                ListFields = ListFields & "Integer"
             Case 4   'Number
                ListFields = ListFields & "Number"
             Case dbDate   'Date
                ListFields = ListFields & "Date"
             Case dbText  'Text
                ListFields = ListFields & "Text"
             Case dbMemo 'Memo
                ListFields = ListFields & "Memo"
          End Select
          ListFields = ListFields & " Size=" & fld.Size & vbCrLf
       Next
       db.Close
    End Function
    For the data, I would export it to excel or link to it from excel and then from excel you can save as a comma delimited text file.
    Rate my response if I helped

    Go Hard Or Go Home


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