Solved

Object Definitions Update for 2010

Posted on 2013-01-20
2
266 Views
Last Modified: 2013-01-20
In Access 2003, a friend helped me to identify objects in a database with the code below.  It no longer works for Office 2010.  Can someone please help me update this code so it's functional and outputs to Excel 2010?

Function tableflds() As String
Dim Dbs As Database
Dim xlapp As Object
Dim hdr As Object
Dim tbls  As RecordsetDefs
Dim fld As Fields
Dim tbl As Integer, r As Integer, c As Integer
Dim x As Object, t As Object
Set Dbs = CurrentDb
Set tbls = Application.CurrentDb.TableDefs
Set xlapp = CreateObject("excel.Application")
xlapp.workbooks.Add
Set hdr = xlapp.activeworkbook.worksheets(1).range("A:A")
xlapp.Visible = True
c = 0
tbl = -1
For Each t In tbls
tbl = tbl + 1
r = 2
c = c + 1
hdr.cells(1, c).value = t.Name
Set fld = tbls(tbl).PageFields 'MOD: Changed from .fieldsl

For Each x In fld
hdr.cells(r, c).value = x.Name
r = r + 1
Next x
Set fld = Nothing
Next t
End Function
0
Comment
Question by:CFMI
2 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 38798476
Try this code:
Public Function tableflds() As String
Dim xlapp As Object
Dim hdr As Object
Dim tbls  As Object
Dim fld As Object
Dim tbl As Integer, r As Integer, c As Integer
Dim x As Object, t As Object
On Error GoTo err1
tableflds = True
Set tbls = Application.CurrentDb.TableDefs
Set xlapp = CreateObject("excel.Application")
xlapp.workbooks.Add
Set hdr = xlapp.activeworkbook.worksheets(1).range("A:A")
xlapp.Visible = True
c = 0
tbl = -1
For Each t In tbls
tbl = tbl + 1
r = 2
c = c + 1
hdr.cells(1, c).Value = t.Name
Set fld = tbls(tbl).Fields 'MOD: Changed from .fieldsl

For Each x In fld
hdr.cells(r, c).Value = x.Name
r = r + 1
Next x
Set fld = Nothing
Next t
Exit Function
err1:
    tableflds = False
End Function

Open in new window

0
 
LVL 1

Author Closing Comment

by:CFMI
ID: 38798515
Perfect.  Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Outlook Free & Paid Tools
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now