Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 27th, 2008, 05:50 AM
Authorized User
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hewstone999
Default 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


Old February 27th, 2008, 10:10 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a list box from comma separated values CoderNH Access VBA 3 October 20th, 2008 08:37 AM
populate a drop list fro a data table greenbriar ADO.NET 2 July 22nd, 2008 10:18 PM
Populating master table with list from list table sburgess Access 7 September 1st, 2006 06:03 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Fill a drop down box with table names? morpheus Classic ASP Basics 10 April 23rd, 2004 08:35 AM

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