The following are the referenced contents: Dim Defdatabase as Database Dim deftable as TableDef, Deffield as Field Set defdatabase = Workspaces (0). OpenDatabase (App.Path & \vb-code). MDB ", 0, False) Set deftable = defdatabase.createtabledef ("China") ' Dbbinary = 9 ' Dbboolean = 1 ' Dbbyte = 2 ' Dbchar=18 ' Dbdate=8 ' Dbinteger=3 ' Dblong=4 ' Dbmemo=12 ' Dbtext=10 ' Create a Name field of 8 characters Set Deffield = Deftable.createfield ("Name", dbtext, 8) DefTable.Fields.Append Deffield Set Deffield = Deftable.createfield ("Sex", dbtext, 2) DefTable.Fields.Append Deffield ' This field is allowed to be empty Deffield.allowzerolength = True ' Create a regular integer with an age field of 3 Set Deffield = Deftable.createfield ("Age", Dbinteger, 3) ' Field append DefTable.Fields.Append Deffield ' Table append DefDatabase.TableDefs.Append deftable MsgBox "All OK, the China" table has been completed! ", vbinformation Exit Sub ERR100: MsgBox "Sorry, could not establish the table. Do you want to build the Vb-code database before you build the table? ", vbcritical End Sub Private Sub Cmdcreate_click () On Error GoTo Err100 ' Establish a database named Vb-code CreateDatabase "Vb-code", dblanggeneral MsgBox "All OK, database setup complete!" ", vbinformation Exit Sub ERR100: MsgBox "Cannot build a database!" & vbCrLf & vbCrLf & Err.Description, vbinformation End Sub |