Function ColumnExists(WhichColumn, WhichTable)
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim WSOrig As Worksheet
Dim WSTemp As Worksheet
Dim fld As ADODB.Field
ColumnExists = False
MyConn = MyConn & "\mydb.mdb"
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn
End With
Set rst = cnn.OpenSchema(adSchemaColumns)
Do Until rst.EOF
If LCase(rst!Column_Name) = LCase(WhichColumn) And _
LCase(rst!Table_Name) = LCase(WhichTable) Then
ColumnExists = True
GoTo ExitMe
End If
rst.MoveNext
Loop
ExitMe:
rst.Close
Set rst = Nothing
cnn.Close
End Function
|