Rename a field name using code with variables

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

    Rename a field name using code with variables

    Hi, can anyone help me with the code necessary to rename a field in an access table. I have tried the ALTER TABLE method but it doesn't like my variable names. Here is the code and thank you for any help!
    ALTER TABLE tblClientTable RENAME COLUMN fldRateField TO "MarketPric e"
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Take the quotes of MarketPrice.



    Originally posted by ineedahelp
    Hi, can anyone help me with the code necessary to rename a field in an access table. I have tried the ALTER TABLE method but it doesn't like my variable names. Here is the code and thank you for any help!
    ALTER TABLE tblClientTable RENAME COLUMN fldRateField TO "MarketPric e"

    Comment

    • ineedahelp
      New Member
      • Sep 2006
      • 98

      #3
      I took the quotes off MarketPrice, but I still get a compile/syntax error and my variable tblClientTable seems to be the problem. Could it be that I haven't declared this variable properly?

      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

      Thank you for any additional help!

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Try:

        Dim fldRateField As Field
        Dim tblClientTable As Table


        Originally posted by ineedahelp
        I took the quotes off MarketPrice, but I still get a compile/syntax error and my variable tblClientTable seems to be the problem. Could it be that I haven't declared this variable properly?

        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

        Thank you for any additional help!

        Comment

        Working...