Delete Field in Backend Database

  • Thread starter Thread starter DT
  • Start date Start date
D

DT

Access 2007 user looking for code that will delete a field from a specified
table on a backend database. AND/OR...change the Field Size on an existing
field. Thanks!
 
No user should have this ability. This is a recipe for disaster!!!!

Anywho, To delete a field you'd do something along the line of

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
set tdf = db.TableDefs ("YourTableName")
tdf.Fields.Delete ("YourFieldName")

or using SQL, something like

Db.Execute "ALTER TABLE YourTableName " & _
"DROP COLUMN YourFieldName;"


As far as resizing a field, check out
http://www.freevbcode.com/ShowCode.asp?ID=4599 for some inspiration.

But as I stated, this is a very bad idea!!!
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
Back
Top