Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    delete field with password (Access 2000)

    I have difficulties with deleting a field called Drake in a table called Students while opening a database with password "Ani"
    My mistake lies definitely with the password,and especially in the line
    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", PWD=" & StrPassword)
    This line obvisouly is wrong and i would like to ask for help.The full code is the following:


    Public Function DeleteField()
    Dim StrPassword As String
    StrPassword = "Ani"

    Dim wsp As DAO.Workspace
    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Set wsp = DAO.DBEngine.Workspaces(0)
    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", PWD=" & StrPassword)
    Set tdf = dbs.TableDefs("Students")
    Set fld = tdf.Fields("Drake")
    tdf.Fields.Delete fld.Name
    tdf.Fields.Refresh
    dbs.Close
    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing
    Set wsp = Nothing
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: delete field with password (Access 2000)

    Replace the line

    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", PWD=" & StrPassword)

    by

    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", False, False, ";PWD=" & strPassword)

    Notes:

    The first False is the Options argument - True means open exclusive, False means open shared.
    The second False is the ReadOnly argument - True means open read-only, False means open read-write.
    The semi-colon ; in the last argument (Connect) is obligatory. The first part of the Connect argument is the database type; for Access this can be omitted.

Posting Permissions

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