Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 27th, 2008, 04:50 AM
Authorized User
 
Join Date: Feb 2008
Location: , , .
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

Richard


Reply With Quote
  #2 (permalink)  
Old February 27th, 2008, 09:10 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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?


mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 12:33 PM.


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