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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View and Edit properties of existing tables. 1

Status
Not open for further replies.

Eldaria

Programmer
Sep 20, 2001
123
NL
I have an Access 2000 Database, and I need to edit an existing table like adding/deleting fields.

I also need to view names and other properties of the fields, but one by one like you can do with the records in the tables, eg. rst.MoveNext, and then i can view store or alter that record. But i want to do the same with a Table's properties, like, tbldef.MoveNextField and then i can do what ever with that field...

The only thing i can find is how to create a new tabel with the tabldefs create. but i can not find anywhere how to edit existing tables.

Hope you understand what i meen...
Eldaria

That was my 25cent** of opinion.

** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.
 
To iterate through a table is equivalent to iterating throught the fields of a table like:

dim db as database
dim tdf as tableDef
dim fld as Field
set db=currentdb 'or opendatabase("C:\whatever.mdb")
db.TableDefs.Refresh

For Each tdf In db.TableDefs
For Each fld In tdf.Fields
'do whatever maybe something like fld.size
Next fld
Next tdf

Alternatively, for a specific table

dim db as database
dim tdf as tableDef
dim fld as Field
set db=currentdb 'or opendatabase("C:\whatever.mdb")
set fld=db.tabledef("SomeTable").fields("someField)


Hope this helps,
Rewdee


 
Thanks, ok, so now i know how to open the exisitng table, and with a little bit of experimenting i can figure out the rest.. :)
Eldaria

That was my 25cent** of opinion.

** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.
 
also check out
ALTER TABLE Statement
in the Help Files

PaulF
 
I Looked up the last one, and I guees it can be used if working directly on SQL tables?

Thanks PaulF, I found some stuff on that, but i think i will stick to the one Rewdee gave me, it apears to be exactly what i need. :)
Eldaria

That was my 25cent** of opinion.

** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.
 
Eldaria, if you would like, I can send you a little Access db that I wrote that allows you to create tables and append fields to tables via code. It's in 97 format, but I think it should convert without too much trouble.

I don't believe that you can change a field's size with code, unless you want to create a new field, import all the records into it, and delete the old field.

Mike Rohde
"I don't have a god complex, god has a me complex!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top