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

How to add a new fields in table by using recordset (VBA)

Status
Not open for further replies.

nadjib

Programmer
May 14, 2003
23
0
0
CA
Hi everybody,

How can I add a fields in table by using Recordset.

I try to use:

--------------------
Dim db As DAO.Database
Dim rst As Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("Table1")

rst.Fields ????? Append dont work

So what is the object how must used in this case, to permet me to add new field like (string or integer)


cordially

 
Use TableDefs instead of Recordset. Here is an example:

Dim tdf as TableDef, fld as Field

Set tdf = db.TableDefs("Table1")
Set fld = tdf.CreateField("FieldName",fieldsize) - the field size is going to be something like dbDouble, dbDate, dbText, etc.)

With tdf.Fields
.Append fld
End With

Hope this is what you were looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top