Article ID: 126223
Article Last Modified on 1/9/2003
Sub Command1_Click ()
Const DB_TEXT = 10
Dim db As database
Dim td As tabledef
Dim fd As Field
On Error Goto AppendTrap
' Open the database and set the tabledef
Set db = OpenDatabase("c:\dBASE", False, False, "dBASE iii")
Set td = db.TableDefs("MyTable")
' Create a new field object and append to the tabledef
Set fd = New Field
fd.Name = "f1"
fd.Type = DB_TEXT
fd.Size = 15 ' Creates a text field length 15 characters
td.Fields.Append fd ' Error occurs here!
db.Close
On Error Goto 0
Exit Sub
AppendTrap:
If Err = 3282 Then
MsgBox "Cannot Modify Table - it contains data!"
Resume Next
Else
MsgBox Error$
On Error Goto 0
Exit Sub
End If
End Sub
Additional query words: 3.00
Keywords: kbprb KB126223