Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

table

Posted on 1999-06-23
1
Medium Priority
?
159 Views
Last Modified: 2010-05-02
How can I fill a list box with all the tables of from a database .MDB file and then choose one table from the list and delete that table. I use DAO/VB6 no data control.


Thanks in advance
0
Comment
Question by:abidsml
[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
1 Comment
 
LVL 1

Accepted Solution

by:
jdunck earned 60 total points
ID: 1519304
Create a project w/ a reference to DAO.

Paste this file into notepad, and save it as Form1.frm.

Add the form to the project you just created.

Change the OpenDatabase argument to the path of your database.

Tada..

  -JDunck


VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdDelete
      Caption         =   "Command1"
      Height          =   615
      Left            =   600
      TabIndex        =   1
      Top             =   2160
      Width           =   1455
   End
   Begin VB.ListBox List1
      Height          =   1035
      Left            =   840
      TabIndex        =   0
      Top             =   720
      Width           =   3255
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mdbDatabase As DAO.Database

Private Sub cmdDelete_Click()
   Dim pstrSQL As String
   
   'remove it from db
   pstrSQL = "DROP TABLE " & List1.Text
   
   mdbDatabase.Execute pstrSQL
   
   'remove it from the list
   List1.RemoveItem List1.ListIndex
   
End Sub

Private Sub Form_Load()
  Dim ptdTable As DAO.TableDef
   
   Set mdbDatabase = OpenDatabase("C:\Audit\Database\audit.mdb")

  For Each ptdTable In mdbDatabase.TableDefs
    List1.AddItem ptdTable.Name
   Next

End Sub


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 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