Alter Table Add Field

harrisw48

New member
Local time
Today, 04:31
Joined
Jan 5, 2005
Messages
9
Im using the cose below to add a new field to a table:

Public Sub AddFields()
Dim Dbs As Database
Set Dbs = CurrentDb
Dbs.Execute ("ALTER TABLE TEMP ADD COLUMN TESTER TEXT(20);")
End Sub

How can I set the new field to allow zero length?
Its default seems to be set to "NO"
 
Using dao is easier.
Code:
Dim db as DAO.Database
Dim tbl as DAO.Tabledef

Set db = CurrentDb
Set tbl = db.TableDefs("Temp")

With tbl
   .Fields.Append .CreateFields("Tester",dbText,20)
   .Fields("Tester").AllowZeroLength = True
End With

set tbl = nothing
db.close
set db = nothing

The field size can be w/ or w/o quotes ("20" or 20)
 

Users who are viewing this thread

Back
Top Bottom