• Rename field in remote db (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Rename field in remote db (Access 2000)

    Author
    Topic
    #388217

    Can i rename a field in a remote DB ? I have a delete function to delete the field, but since the field is a part of a connection
    i cannot delete it.However renaming the field from ContactID to CustomerID will do the job for me.

    Below is my delete function.I will be grateful if somebody help me rebuilding it to a rename function only.:

    Dim wsp As DAO.Workspace
    Dim StrPassword As String
    StrPassword = “password”
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Set wsp = DAO.DBEngine.Workspaces(0)
    Dim dbs As DAO.Database
    Set dbs = wsp.OpenDatabase(“C:BEstoreBE.mdb”, False, False,

    “;PWD=” & StrPassword)
    Set tdf = dbs.TableDefs(“CallsCustomers”)
    Set fld = tdf.Fields(“ContactID”)
    tdf.Fields.Delete fld.Name
    tdf.Fields.Refresh
    dbs.Close
    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing
    Set wsp = Nothing
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #680672

      i want to explain further what i have done with the hope that i will be more clear and thus receive the help i need

      I have tried to build the code but i received

      an error in the line tdf.Fields.Name = “CustomerID” with the message
      ” method or data member not found.” Can you help me build the right way ? Below is my code

      Dim wsp As DAO.Workspace
      Dim StrPassword As String
      StrPassword = “password”
      Dim tdf As DAO.TableDef
      Dim fld As DAO.Field
      Set wsp = DAO.DBEngine.Workspaces(0)
      Dim dbs As DAO.Database
      Set dbs = wsp.OpenDatabase(“C:BEstoreBE.mdb”, False, False,

      “;PWD=” & StrPassword)
      Set tdf = dbs.TableDefs(“CallsCustomers”)
      Set fld = tdf.Fields(“ContactID”)
      tdf.Fields.Name = “CustomerID”
      tdf.Fields.Refresh
      dbs.Close
      Set fld = Nothing
      Set tdf = Nothing
      Set dbs = Nothing
      Set wsp = Nothing

      • #680682

        I may be wrong, but I would change your instruction:
        tdf.Fields.Name = “CustomerID”
        to:
        fld.Name = “CustomerID”

    Viewing 0 reply threads
    Reply To: Rename field in remote db (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: