Databases Reference
In-Depth Information
For i = 1 To UBound(Fields)
TotalFieldNames = TotalFieldNames + 1
ReDim Preserve FieldNames(1 To TotalFieldNames)
FieldNames(TotalFieldNames) = Fields(i, 1)
GetFieldNames = TotalFieldNames
Next i
'Close the connection to the database
SQLClose (Chan)
Exit Function
No_Table:
MsgBox SQLOpenString, vbOKOnly + vbCritical, "Error: The
Referenced Table Does Not Exist in "
GetFieldNames = 0
'Close the connection to the database
SQLClose (Chan)
End Function
subroutine that actually takes the array passed back from the
preceding function and utilizes it to populate the combo box on the form. The subroutine is triggered
in the program any time the table name changes in the Table Name combo box in the Remove
Field section of the GUI.
It is the
PopulateFieldsNF
Sub PopulateFieldsNF(TableName As String)
'Populate the Fields (Columns) Combobox
Dim Fields() As Variant
Call GetFieldNames("DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=" & frm7NewField.Label_AFile.Caption, TableName,
Fields())
frm7NewField.ComboBox_Fields.AddItem "*"
For i = 1 To UBound(Fields)
frm7NewField.ComboBox_Fields.AddItem Fields(i)
Next i
End Sub
Once all the field names have been populated to the combo box, the user may select one at
will to be deleted. The function
will delete a specified field in a specified
table using DAO. If the deletion is successful, the function will return the Boolean value of True.
DeleteFieldDAO
Function DeleteFieldDAO(fullmdbpath As String, TableName As
String, ColumnName As String) As Boolean
'Adds a Column named ColumnName to Table named TableName in
the Specified Database
Dim MCSdb As Database
Dim ws As Workspace
Dim tbl As TableDef
Dim ConnectString As String
Search WWH ::




Custom Search