Hi,
I wrote this little function as part of an ETL procedure. It's simply to help me change column names in my access table, in VBA..
Public Sub change_col_name(TableName As String, OldColName As String, NewColName As String)
Dim tblDef As TableDef
Dim fldDef As Field
Set tblDef = CurrentDb.TableDefs(TableName)
For Each fldDef In tblDef.Fields
If fldDef.Name = OldColName Then
fldDef.Name = NewColName
Exit For
End If
Next fldDef
tblDef.RefreshLink
CurrentDb.TableDefs.Refresh
End Sub
For some reason I get an error 3420 on the "For each" line..
I'm grateful for any advice..
I wrote this little function as part of an ETL procedure. It's simply to help me change column names in my access table, in VBA..
Public Sub change_col_name(TableName As String, OldColName As String, NewColName As String)
Dim tblDef As TableDef
Dim fldDef As Field
Set tblDef = CurrentDb.TableDefs(TableName)
For Each fldDef In tblDef.Fields
If fldDef.Name = OldColName Then
fldDef.Name = NewColName
Exit For
End If
Next fldDef
tblDef.RefreshLink
CurrentDb.TableDefs.Refresh
End Sub
For some reason I get an error 3420 on the "For each" line..
I'm grateful for any advice..