home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap14 / vbu1403l.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-10-07  |  1.6 KB  |  58 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. Attribute VB_Name = "Form1"
  16. Attribute VB_Creatable = False
  17. Attribute VB_Exposed = False
  18. Option Explicit
  19. Public Sub NewData()
  20.     '
  21.     ' create a new database
  22.     '
  23.     Dim dbFile As Database
  24.     Dim cDBFile As String
  25.     Dim cTable1 As String
  26.     Dim cTable2 As String
  27.     Dim nTemp As Integer
  28.     '
  29.     ' set vars
  30.     cDBFile = "ch1401.mdb"
  31.     cTable1 = "CREATE TABLE Table1 (CustID TEXT(10),CustName TEXT(30),CustType TEXT(10));"
  32.     cTable2 = "CREATE TABLE Table2 (CustType TEXT(10),TypeName TEXT(20));"
  33.     '
  34.     ' kill any current database
  35.     nTemp = MsgBox("Ready to Delete Any Existing Database?", vbInformation + vbYesNo, "Create Database")
  36.     If nTemp = vbNo Then
  37.         MsgBox "Create Database Canceled"
  38.     Else
  39.         On Error Resume Next
  40.         Kill cDBFile
  41.         On Error GoTo 0
  42.         '
  43.         ' create empty DB
  44.         Set dbFile = DBEngine.CreateDatabase(cDBFile, dbLangGeneral)
  45.         '
  46.         ' create tables
  47.         dbFile.Execute cTable1
  48.         dbFile.Execute cTable2
  49.         '
  50.         ' add additional tables, indexes, relations, etc.
  51.         '
  52.         MsgBox "Database has been Created"
  53.     End If
  54. End Sub
  55. Private Sub Form_Load()
  56.     NewData
  57. End Sub
  58.