Databases Reference
In-Depth Information
FIGURE 8.3
Sample application to create database tables in Excel.
Figure 8.3 shows the sample application that can be run by selecting ADA->Chapter 8->Add
Table to Database from the Excel Menu. If a database has been selected in the past, the application
will remember this by utilizing the Windows Registry. If a previous database is stored in the
Windows Registry when the application is run, the program will populate the “Current Database
Tables” combo box with the names of all the tables in the database that
system tables. This
process begins when the application is initialized. The color-coding scheme should help the reader
comprehend the series of events that take place.
are not
Private Sub UserForm_Initialize()
'Retrieve Registry Settings
If GetSetting("AccessCT", "File", "FullPath") <> "" Then
frm7NewTable.Label_AFile.Caption = GetSetting("AccessCT",
"File", "FullPath")
Call PopulateTablesNT
frm7NewTable.StatusBar.SimpleText = "Add a New Table to the
Database . . ."
Else
frm7NewTable.StatusBar.SimpleText = "Select Access Database
for Query . . ."
End If
End Sub
subroutine populates the combobox in the GUI
with the names of the tables in the database selected by the user. The subroutine is dependent on
two functions:
Once initialized, the
PopulateTablesNT
and
.
GetTableNames
IsSystemTable
Sub PopulateTablesNT
()
'Populate the Database Tables Combobox
Dim Tables() As Variant
Call GetTableNames
("DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=" & frm7NewTable.Label_AFile.Caption, Tables())
For i = 1 To UBound(Tables)
If IsSystemTable
((Tables(i))) = False Or Tables(i) =
"MSysAccessObjects" Then
frm7NewTable.ComboBox_Tables.AddItem Tables(i)
Search WWH ::




Custom Search