p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Populate a List Box with Table Names & Table date (http://p2p.wrox.com/showthread.php?t=66212)

hewstone999 February 27th, 2008 05:50 AM

Populate a List Box with Table Names & Table date
I have 2 questions/problems:

1. I want to populate a list box with all the Tables Names in my Database using VBA.

2. I also want to create another List Box or Grid (or any thing that will show table data) that when i have select a Table Name (See above (1)) it will show all the data in that table in the List Box. Was thinking some kind of SQL using vba to populate the list box?

Any ideas or help will be much appreciated


mmcdonal February 27th, 2008 10:10 AM

Here is code I used to populate a list box, called List2, with all the tables names in the database on the form On Load event:

Private Sub Form_Load()
Dim obj As AccessObject
Dim dbs As Object
Dim ctrlListBox As ListBox

Set dbs = Application.CurrentData
Set ctrlListBox = Me.List2

    With ctrlListBox
     For Each obj In dbs.AllTables

        .AddItem Item:=obj.Name

     Next obj
    End With

End Sub

This shows system tables so you are going to have to remove those from the list if you don't want them selected. Do you need more help?


Look it up at: http://wrox.books24x7.com

All times are GMT -4. The time now is 07:12 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.