?
Solved

Object Definitions Update for 2010

Posted on 2013-01-20
2
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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…

801 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