Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting fields in Access using VB

Status
Not open for further replies.

wala

Programmer
Aug 2, 2000
6
PH
could anybody please help me on how to delete a specific field in a Table.

I had tried this code...

Code:
Dim cat As New ADOX.Catalog

    cat.ActiveConnection = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=d:\sample.mdb;"

    cat.Procedures.Delete "TPYID"

but an error message "ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application" appears.

Does this mean that Access does not allow any deletion of fields using Visual Basic?

Thank you in advance. :cool: [sig][/sig]
 
No, it means it couldnt find a field called "TPYID", is that the correct fieldname, or should it be "TYPID" or spelled some other way? usually this error means you misspelled a fieldname. [sig][/sig]
 
Using cat.Procedures.delete will delete a procedure named "TPYID", which is why you get the error you did.
If you want to delete a column from a table, use:

cat.Tables.Item("TableName").Columns.Delete "TPYID"

Simon [sig][/sig]
 
thanks a lot. s-) [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top