Results 1 to 4 of 4

Thread: (Resolved) Delete a field from an Access database

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    78

    (Resolved) Delete a field from an Access database

    Good morning,

    Is there a way to delete an entire field from an Access database?

    If not, is there a way to replace all the values in this field to Null?

    Access 2002, VB6/ADO

    The name of the field is static but it's location will not always be the same, nor will the names of the other fields. This is a very messy database that I'm trying to clean up so that I can get the information that I need from it.

    Thanks,
    Mary
    Last edited by A441OTA; Jul 9th, 2002 at 07:29 AM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    78

    Sorry for the multiple posts

    I kept getting error messages, so I kept trying..... sorry for the blank threads, I don't know how to delete them.

    Thanks,
    Mary

  3. #3
    Hyperactive Member maxl's Avatar
    Join Date
    Jan 2002
    Location
    Montréal
    Posts
    384
    Not sure it that helps but you can always use a connection to execute an SQL statement.
    VB Code:
    1. Dim SQL as String
    2. Dim Conn as New Adodb.Connection
    3.  
    4. 'Open your conn here with the right connection string
    5. Conn.Open ConnectionString
    6.  
    7.  
    8. 'Drop the field
    9. SQL="ALTER TABLE table_name DROP COLUMN field_Name"
    10. Conn.Execute SQL
    11. 'Set all to NULL
    12. SQL="UPDATE table_name SET field_name=NULL"
    13. Conn.Execute SQL
    14. Conn.Close
    15. Set Conn = Nothing
    16. 'You can always replace the field and table name with variables to do this dynamicly

    Hope that helped
    COBOL sa suce !!!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    78

    Talking Thank you Max!

    Thank you Max!!!

    I wasn't sure if you could delete a field -- if this works you are a lifesaver!!!! I won't be able to try it today, but will try as soon as possible. This is the messiest database and cleaning it up is imperative to finding the data needed!!!

    I owe you a beer next time you're in Virginia!!!!

Posting Permissions

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



Click Here to Expand Forum to Full Width