VBA code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I write code to insert a field into a table and then the field type
 
Here is some code that uses the DAO object library:

Dim db As DAO.Database
Dim tdef As DAO.TableDef
Dim fld As DAO.Field
Set db = CurrentDb
Set tdef = db.TableDefs("tblCaseCount")
With tdef
.Fields.Append .CreateField("FirstHrCases", dbDouble)
.Fields.Append .CreateField("FirstHrComments", dbText, 75)
.Fields.Append .CreateField("ChangeOver", dbBoolean)
.Fields.Append .CreateField("UpdateBy", dbText, 20)
.Fields.Append .CreateField("UpdateWhen", dbDate)
End With
set tdef = nothing
Set db = Nothing
 
How do I write code to insert a field into a table and then the field
type

sqlCommand = _
"ALTER TABLE MyTable " & _
"ADD COLUMN MyNewColumn INTEGER"

CurrentDB().Execute sqlCommand, dbFailOnError



Hope that helps


Tim F
 

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

Back
Top