ALTER TABLE to rename a field with a variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ineedahelp
    New Member
    • Sep 2006
    • 98

    ALTER TABLE to rename a field with a variable

    I am trying to rename a field (fldRateField) in a table (tblClientTable ). Whenever I run this code, I get a compile error and the "tblClientTable " variable is highlighted. Any help as to why it doesn't like my variable?

    Dim fldRateField As String
    Dim tblClientTable As String
    fldRateField = Forms!frmDailyC lient!lstFieldL ist
    tblClientTable = Forms!frmDailyC lient!lstTableL ist
    ALTER TABLE tblClientTable RENAME COLUMN fldRateField TO MarketPrice
  • comteck
    New Member
    • Jun 2006
    • 179

    #2
    I don't know if you can rename a field on the fly. If you can, it's not done with the ALTER TABLE statement. ADD COLUMN or ALTER COLUMN can only be used with ALTER TABLE. RENAME COLUMN cannot be used.

    You may have to rename the field from the design view of the table. Just a word of caution.... if you rename fields in your table, it may affect all queries, forms, etc. that are associated with that table.

    comteck

    Comment

    Working...