home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap14 / vbu1403l.frm < prev    next >
Text File  |  1995-10-07  |  2KB  |  63 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   4140
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1512
  7.    ClientWidth     =   6696
  8.    Height          =   4524
  9.    Left            =   1092
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4140
  12.    ScaleWidth      =   6696
  13.    Top             =   1176
  14.    Width           =   6792
  15. End
  16. Attribute VB_Name = "Form1"
  17. Attribute VB_Creatable = False
  18. Attribute VB_Exposed = False
  19. Option Explicit
  20.  
  21. Public Sub NewData()
  22.     '
  23.     ' create a new database
  24.     '
  25.     Dim dbFile As Database
  26.     Dim cDBFile As String
  27.     Dim cTable1 As String
  28.     Dim cTable2 As String
  29.     Dim nTemp As Integer
  30.     '
  31.     ' set vars
  32.     cDBFile = "ch1401.mdb"
  33.     cTable1 = "CREATE TABLE Table1 (CustID TEXT(10),CustName TEXT(30),CustType TEXT(10));"
  34.     cTable2 = "CREATE TABLE Table2 (CustType TEXT(10),TypeName TEXT(20));"
  35.     '
  36.     ' kill any current database
  37.     nTemp = MsgBox("Ready to Delete Any Existing Database?", vbInformation + vbYesNo, "Create Database")
  38.     If nTemp = vbNo Then
  39.         MsgBox "Create Database Canceled"
  40.     Else
  41.         On Error Resume Next
  42.         Kill cDBFile
  43.         On Error GoTo 0
  44.         '
  45.         ' create empty DB
  46.         Set dbFile = DBEngine.CreateDatabase(cDBFile, dbLangGeneral)
  47.         '
  48.         ' create tables
  49.         dbFile.Execute cTable1
  50.         dbFile.Execute cTable2
  51.         '
  52.         ' add additional tables, indexes, relations, etc.
  53.         '
  54.         MsgBox "Database has been Created"
  55.     End If
  56. End Sub
  57.  
  58. Private Sub Form_Load()
  59.     NewData
  60. End Sub
  61.  
  62.  
  63.