[AccessD] [dba-OT] Transfer field names to excel,
Jim Lawrence
accessd at shaw.ca
Sat Oct 14 02:09:16 CDT 2017
Well that definitely works...well done.
Jim
----- Original Message -----
From: "stuart" <stuart at lexacorp.com.pg>
To: "Off Topic" databaseadvisors.com>, "Access Developers discussion and problem solving" <accessd at databaseadvisors.com>
Sent: Thursday, October 12, 2017 3:23:49 PM
Subject: Re: [AccessD] [dba-OT] Transfer field names to excel,
On 12 Oct 2017 at 14:43, Rocky Smolin wrote:
> Martin:
>
> Lot of good tools there but didn't see one that would get the field
> names into an Excel sheet. I'll keep looking, though.
>
>
Just knocked this up for you. You can open the resultant Tab delimited text file in Excel.
Function GetTableData() As Long
Dim Tbls() As String
Dim t As TableDef
Dim f As Field
Dim x As Long
Dim y As Long
Dim tblCount As Long
Dim maxfields As Long
'Get required array dimension
For Each t In CurrentDb.TableDefs
If Left$(t.Name, 4) <> "mSys" Then
tblCount = tblCount + 1
y = t.Fields.Count
If y > maxfields Then maxfields = y
End If
Next
ReDim Tbls(1 To tblCount, 0 To maxfields)
'get table and field names into array
For Each t In CurrentDb.TableDefs
If Left$(t.Name, 4) <> "mSys" Then
x = x + 1
y = 0
Tbls(x, 0) = t.Name
For Each f In t.Fields
y = y + 1
Tbls(x, y) = f.Name
Next
End If
Next
'Export to tab delimited file
Open CurrentProject.Path & "\TableFieldNames.txt" For Output As #1
For y = 0 To maxfields
For x = 1 To tblCount - 1
Print #1, Tbls(x, y) & Chr$(9);
Next
Print #1, Tbls(tblCount, y)
Next
Close #1
MsgBox "Done"
End Function
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
More information about the AccessD
mailing list