[AccessD] changing fieldname

Gustav Brock Gustav at cactus.dk
Wed May 4 03:30:36 CDT 2005


Hi Pedro

Not sure about SQL but piece of cake with DAO on local tables.
If it is in the backend, you need to modify the code to open the
backend database:

Public Sub ChangeFieldName( _
  ByVal strTable As String, _
  ByVal strFieldName As String, _
  ByVal strFieldNameNew As String)

  Dim dbs As DAO.Database
  Dim tdf As DAO.TableDef
  Dim fld As DAO.Field
  
  Set dbs = CurrentDb
  Set tdf = dbs.TableDefs(strTable)
  Set fld = tdf.Fields(strFieldName)
  
  fld.Name = strFieldNameNew
  
  Set fld = Nothing
  Set tdf = Nothing
  Set dbs = Nothing
  
End Sub

/gustav

>>> pedro at plex.nl 05/03 11:45 pm >>>
Hello All,

can i change a fieldname of a table with a definition query and ALTER
TABLE tablename ALTER COLUMN  ?
If not can it been done in sql or in code and how??

Pedro Janssen




More information about the AccessD mailing list