Delete Field in Backend Database

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!
 
D

Daniel Pineault

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top