PC Review


Reply
Thread Tools Rate Thread

How Do I Build a List of Field Names I can Export to Excel

 
 
=?Utf-8?B?bHBibG92ZQ==?=
Guest
Posts: n/a
 
      29th Oct 2007
I do not want to use the documenter, because I want a file that I can export
to excel, not a report format.
 
Reply With Quote
 
 
 
 
'69 Camaro
Guest
Posts: n/a
 
      29th Oct 2007
Hi.

>I do not want to use the documenter, because I want a file that I can
>export
> to excel, not a report format.


If you're interested in the field names as columns in the spreadsheet, then
use a query to export an empty table, with only the column headers, to a
spreadsheet:

SELECT * INTO [Text;HDR=YES;DATABASE=C:\Data\].FieldNames.CSV
FROM MyTable
WHERE (1 = 0);

Then open the C:\Data\FieldNames.CSV file in Excel.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.


 
Reply With Quote
 
=?Utf-8?B?bHBibG92ZQ==?=
Guest
Posts: n/a
 
      29th Oct 2007
hat was a great suggestion. Thank you. Unfortunately, I didn't explain
fully, I apologize...

I want to have the information as if I had used the documenter, just not the
report format the documenter generates. So Field Names and the field
Properties. It would be fine to even build a table with this info so I can
export it when I want to. I am having trouble finding out how to get both
the field names and properties. Thank you.

"'69 Camaro" wrote:

> Hi.
>
> >I do not want to use the documenter, because I want a file that I can
> >export
> > to excel, not a report format.

>
> If you're interested in the field names as columns in the spreadsheet, then
> use a query to export an empty table, with only the column headers, to a
> spreadsheet:
>
> SELECT * INTO [Text;HDR=YES;DATABASE=C:\Data\].FieldNames.CSV
> FROM MyTable
> WHERE (1 = 0);
>
> Then open the C:\Data\FieldNames.CSV file in Excel.
>
> HTH.
> Gunny
>
> See http://www.QBuilt.com for all your database needs.
> See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
> Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
> http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
> info.
>
>
>

 
Reply With Quote
 
'69 Camaro
Guest
Posts: n/a
 
      30th Oct 2007
Hi.

> I am having trouble finding out how to get both
> the field names and properties.


Use the DAO library for the Field.Name, Field.Property.Name, and
Field.Property.Value Properties. For an example, first create a query that
creates a table to hold the data:

CREATE TABLE tblColNames
(ID COUNTER (1, 1),
TableName Text (64) NOT NULL,
ColName Text (64) NOT NULL,
PropName Text (35) NOT NULL,
PropValue Text (255),
CONSTRAINT PrimaryKey PRIMARY KEY (ID),
CONSTRAINT UQ_IDX UNIQUE (TableName, ColName, PropName));

And then try the following VBA procedure:

Public Function getColNamesAndProps()

On Error GoTo ErrHandler

Dim db As Database
Dim tbl As TableDef
Dim fld As DAO.Field
Dim prp As DAO.Property
Dim sqlStmt As String
Dim fSkipExecute As Boolean

Set db = CurrentDb()

For Each tbl In db.TableDefs
If ((Mid$(tbl.Name, 1, 4) <> "MSys") And _
(Mid$(tbl.Name, 1, 7) <> "~TMPCLP")) Then
For Each fld In tbl.Fields
For Each prp In fld.Properties
sqlStmt = "INSERT INTO tblColNames (TableName, " & _
"ColName, PropName, PropValue) " & _
"VALUES ('" & Replace(tbl.Name, "'", "''", 1, -1, _
vbDatabaseCompare) & "', '" & Replace(fld.Name,
_
"'", "''", 1, -1, vbDatabaseCompare) & "', '" &
_
prp.Name & "', '" & Replace(CStr(prp.Value),
"'", "''", _
1, -1, vbDatabaseCompare) & "');"

If (Not (fSkipExecute)) Then
db.Execute sqlStmt, dbFailOnError
Else
fSkipExecute = False ' Reset.
End If
Next prp
Next fld
End If
Next tbl

CleanUp:

Set prp = Nothing
Set fld = Nothing
Set tbl = Nothing
Set db = Nothing

Exit Function

ErrHandler:

If ((Err.Number = 3219) Or (Err.Number = 3251) Or (Err.Number = 3267))
Then
Err.Clear
fSkipExecute = True
Resume Next
Else
MsgBox "Error in getColNamesAndProps( )." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
End If

Err.Clear
GoTo CleanUp

End Function

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.


 
Reply With Quote
 
HELENA SMITH
Guest
Posts: n/a
 
      30th Oct 2007
(E-Mail Removed) hi are you
"lpblove" <(E-Mail Removed)> wrote in message
news:10629E31-54C5-4F87-8C8C-(E-Mail Removed)...
> I do not want to use the documenter, because I want a file that I can

export
> to excel, not a report format.



 
Reply With Quote
 
HELENA SMITH
Guest
Posts: n/a
 
      30th Oct 2007
sweet37helena@googlecom hi are you
"lpblove" <(E-Mail Removed)> wrote in message
news:10629E31-54C5-4F87-8C8C-(E-Mail Removed)...
> I do not want to use the documenter, because I want a file that I can

export
> to excel, not a report format.



 
Reply With Quote
 
=?Utf-8?B?bHBibG92ZQ==?=
Guest
Posts: n/a
 
      30th Oct 2007
Worked perfect. Thank you so much!

"'69 Camaro" wrote:

> Hi.
>
> > I am having trouble finding out how to get both
> > the field names and properties.

>
> Use the DAO library for the Field.Name, Field.Property.Name, and
> Field.Property.Value Properties. For an example, first create a query that
> creates a table to hold the data:
>
> CREATE TABLE tblColNames
> (ID COUNTER (1, 1),
> TableName Text (64) NOT NULL,
> ColName Text (64) NOT NULL,
> PropName Text (35) NOT NULL,
> PropValue Text (255),
> CONSTRAINT PrimaryKey PRIMARY KEY (ID),
> CONSTRAINT UQ_IDX UNIQUE (TableName, ColName, PropName));
>
> And then try the following VBA procedure:
>
> Public Function getColNamesAndProps()
>
> On Error GoTo ErrHandler
>
> Dim db As Database
> Dim tbl As TableDef
> Dim fld As DAO.Field
> Dim prp As DAO.Property
> Dim sqlStmt As String
> Dim fSkipExecute As Boolean
>
> Set db = CurrentDb()
>
> For Each tbl In db.TableDefs
> If ((Mid$(tbl.Name, 1, 4) <> "MSys") And _
> (Mid$(tbl.Name, 1, 7) <> "~TMPCLP")) Then
> For Each fld In tbl.Fields
> For Each prp In fld.Properties
> sqlStmt = "INSERT INTO tblColNames (TableName, " & _
> "ColName, PropName, PropValue) " & _
> "VALUES ('" & Replace(tbl.Name, "'", "''", 1, -1, _
> vbDatabaseCompare) & "', '" & Replace(fld.Name,
> _
> "'", "''", 1, -1, vbDatabaseCompare) & "', '" &
> _
> prp.Name & "', '" & Replace(CStr(prp.Value),
> "'", "''", _
> 1, -1, vbDatabaseCompare) & "');"
>
> If (Not (fSkipExecute)) Then
> db.Execute sqlStmt, dbFailOnError
> Else
> fSkipExecute = False ' Reset.
> End If
> Next prp
> Next fld
> End If
> Next tbl
>
> CleanUp:
>
> Set prp = Nothing
> Set fld = Nothing
> Set tbl = Nothing
> Set db = Nothing
>
> Exit Function
>
> ErrHandler:
>
> If ((Err.Number = 3219) Or (Err.Number = 3251) Or (Err.Number = 3267))
> Then
> Err.Clear
> fSkipExecute = True
> Resume Next
> Else
> MsgBox "Error in getColNamesAndProps( )." & _
> vbCrLf & vbCrLf & _
> "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
> End If
>
> Err.Clear
> GoTo CleanUp
>
> End Function
>
> HTH.
> Gunny
>
> See http://www.QBuilt.com for all your database needs.
> See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
> Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
> http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
> info.
>
>
>

 
Reply With Quote
 
'69 Camaro
Guest
Posts: n/a
 
      30th Oct 2007
> Worked perfect. Thank you so much!

You're welcome! Glad it helped.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I export from Access to Excel using field names not captions? Penny Green Microsoft Access External Data 0 5th May 2009 04:34 PM
export list of field names CuriousMark Microsoft Access Queries 2 1st Aug 2008 05:28 PM
Export list of table names to an excel file parth Microsoft Access 1 21st Mar 2007 03:41 PM
Excel Export - Field Names in First Row of Spreadsheet =?Utf-8?B?UmljaDEyMzQ=?= Microsoft Access External Data 18 21st Oct 2005 03:03 PM
Excel Export- Field Names in first row of spreadsheet =?Utf-8?B?UmljaDEyMzQ=?= Microsoft Access Macros 1 12th Oct 2005 12:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:12 AM.