Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Rename field in remote db (Access 2000)

    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

  2. #2
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Added explanation

    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

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Added explanation

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •