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.
Printable View
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.
Not sure if you need to export list of fields only or the entire table. :confused:
In case of an entire table then you can automate MS Access but what language do you use? Or you develop inside Access itself?
You want the field names or the data?
For field names, I wrote this last week.
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.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