home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch03code / createdb.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-15  |  36.0 KB  |  1,215 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Database Creation Program"
  4.    ClientHeight    =   5775
  5.    ClientLeft      =   1350
  6.    ClientTop       =   960
  7.    ClientWidth     =   6720
  8.    Height          =   6240
  9.    Left            =   1260
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5775
  12.    ScaleWidth      =   6720
  13.    Top             =   585
  14.    Width           =   6900
  15.    Begin VB.CommandButton Command14 
  16.       Caption         =   "Create Salesmen Data"
  17.       Height          =   375
  18.       Left            =   2280
  19.       TabIndex        =   22
  20.       Top             =   3960
  21.       Width           =   2175
  22.    End
  23.    Begin VB.CommandButton Command13 
  24.       Caption         =   "Create Retail Items Index"
  25.       Height          =   375
  26.       Left            =   3960
  27.       TabIndex        =   20
  28.       Top             =   3000
  29.       Width           =   2535
  30.    End
  31.    Begin VB.CommandButton Command12 
  32.       Caption         =   "Create Customer Index"
  33.       Height          =   375
  34.       Left            =   240
  35.       TabIndex        =   19
  36.       Top             =   3000
  37.       Width           =   2295
  38.    End
  39.    Begin VB.CommandButton Command11 
  40.       Caption         =   "Create Order and Sales Data"
  41.       Height          =   375
  42.       Left            =   3720
  43.       TabIndex        =   15
  44.       Top             =   4560
  45.       Width           =   2775
  46.    End
  47.    Begin VB.CommandButton Command10 
  48.       Caption         =   "Add Retail Items"
  49.       Height          =   375
  50.       Left            =   4680
  51.       TabIndex        =   14
  52.       Top             =   3960
  53.       Width           =   1815
  54.    End
  55.    Begin VB.CommandButton Command9 
  56.       Caption         =   "Add SalesID to Customer"
  57.       Height          =   375
  58.       Left            =   240
  59.       TabIndex        =   13
  60.       Top             =   4560
  61.       Width           =   2415
  62.    End
  63.    Begin VB.PictureBox Picture1 
  64.       BackColor       =   &H00FF0000&
  65.       Height          =   495
  66.       Left            =   1680
  67.       ScaleHeight     =   465
  68.       ScaleWidth      =   3105
  69.       TabIndex        =   10
  70.       Top             =   5280
  71.       Visible         =   0   'False
  72.       Width           =   3135
  73.       Begin VB.TextBox Text2 
  74.          Height          =   285
  75.          Left            =   1560
  76.          TabIndex        =   12
  77.          Text            =   "Text2"
  78.          Top             =   120
  79.          Width           =   1335
  80.       End
  81.       Begin VB.Label Label2 
  82.          BackColor       =   &H00FFFFFF&
  83.          Caption         =   "Processing Record"
  84.          Height          =   255
  85.          Left            =   120
  86.          TabIndex        =   11
  87.          Top             =   120
  88.          Width           =   1455
  89.       End
  90.    End
  91.    Begin VB.CommandButton Command8 
  92.       Caption         =   "Create Customer Data"
  93.       Height          =   375
  94.       Left            =   240
  95.       TabIndex        =   9
  96.       Top             =   3960
  97.       Width           =   1815
  98.    End
  99.    Begin VB.CommandButton Command7 
  100.       Caption         =   "Create remaining tables"
  101.       Height          =   375
  102.       Left            =   4320
  103.       TabIndex        =   8
  104.       Top             =   2160
  105.       Width           =   2175
  106.    End
  107.    Begin VB.CommandButton Command6 
  108.       Caption         =   "Create Orders Table"
  109.       Height          =   375
  110.       Left            =   240
  111.       TabIndex        =   7
  112.       Top             =   2160
  113.       Width           =   2175
  114.    End
  115.    Begin VB.CommandButton Command5 
  116.       Caption         =   "Create Retail Items Table"
  117.       Height          =   375
  118.       Left            =   4440
  119.       TabIndex        =   6
  120.       Top             =   1680
  121.       Width           =   2055
  122.    End
  123.    Begin VB.CommandButton Command4 
  124.       Caption         =   "Create Customers Table"
  125.       Height          =   375
  126.       Left            =   2280
  127.       TabIndex        =   5
  128.       Top             =   1680
  129.       Width           =   1935
  130.    End
  131.    Begin VB.CommandButton Command3 
  132.       Caption         =   "Create Salesmen Table"
  133.       Height          =   375
  134.       Left            =   240
  135.       TabIndex        =   4
  136.       Top             =   1680
  137.       Width           =   1815
  138.    End
  139.    Begin VB.TextBox Text1 
  140.       Height          =   285
  141.       Left            =   2400
  142.       TabIndex        =   2
  143.       Text            =   "Text1"
  144.       Top             =   120
  145.       Width           =   3855
  146.    End
  147.    Begin VB.CommandButton Command2 
  148.       Caption         =   "New File Name"
  149.       Height          =   375
  150.       Left            =   240
  151.       TabIndex        =   1
  152.       Top             =   840
  153.       Width           =   2175
  154.    End
  155.    Begin VB.CommandButton Command1 
  156.       Caption         =   "Create Database"
  157.       Height          =   375
  158.       Left            =   4200
  159.       TabIndex        =   0
  160.       Top             =   840
  161.       Width           =   2175
  162.    End
  163.    Begin VB.Line Line9 
  164.       X1              =   240
  165.       X2              =   6480
  166.       Y1              =   5160
  167.       Y2              =   5160
  168.    End
  169.    Begin VB.Line Line8 
  170.       X1              =   3960
  171.       X2              =   6480
  172.       Y1              =   3720
  173.       Y2              =   3720
  174.    End
  175.    Begin VB.Line Line7 
  176.       X1              =   240
  177.       X2              =   2520
  178.       Y1              =   3720
  179.       Y2              =   3720
  180.    End
  181.    Begin VB.Label Label6 
  182.       Caption         =   "Load Test Data"
  183.       Height          =   255
  184.       Left            =   2640
  185.       TabIndex        =   21
  186.       Top             =   3600
  187.       Width           =   1215
  188.    End
  189.    Begin VB.Line Line6 
  190.       X1              =   3960
  191.       X2              =   6480
  192.       Y1              =   2760
  193.       Y2              =   2760
  194.    End
  195.    Begin VB.Line Line5 
  196.       X1              =   240
  197.       X2              =   2640
  198.       Y1              =   2760
  199.       Y2              =   2760
  200.    End
  201.    Begin VB.Label Label5 
  202.       Caption         =   "Index Creation"
  203.       Height          =   255
  204.       Left            =   2760
  205.       TabIndex        =   18
  206.       Top             =   2640
  207.       Width           =   1095
  208.    End
  209.    Begin VB.Line Line4 
  210.       X1              =   3960
  211.       X2              =   6480
  212.       Y1              =   1440
  213.       Y2              =   1440
  214.    End
  215.    Begin VB.Line Line3 
  216.       X1              =   240
  217.       X2              =   2640
  218.       Y1              =   1440
  219.       Y2              =   1440
  220.    End
  221.    Begin VB.Label Label4 
  222.       Caption         =   "Table Creation"
  223.       Height          =   255
  224.       Left            =   2760
  225.       TabIndex        =   17
  226.       Top             =   1320
  227.       Width           =   1095
  228.    End
  229.    Begin VB.Line Line2 
  230.       X1              =   4080
  231.       X2              =   6480
  232.       Y1              =   600
  233.       Y2              =   600
  234.    End
  235.    Begin VB.Line Line1 
  236.       X1              =   240
  237.       X2              =   2400
  238.       Y1              =   600
  239.       Y2              =   600
  240.    End
  241.    Begin VB.Label Label3 
  242.       Caption         =   "Database Creation"
  243.       Height          =   255
  244.       Left            =   2520
  245.       TabIndex        =   16
  246.       Top             =   480
  247.       Width           =   1455
  248.    End
  249.    Begin VB.Label Label1 
  250.       Caption         =   "Current Database File Name:"
  251.       Height          =   255
  252.       Left            =   240
  253.       TabIndex        =   3
  254.       Top             =   120
  255.       Width           =   2175
  256.    End
  257.    Begin MSComDlg.CommonDialog GetFile 
  258.       Left            =   6240
  259.       Top             =   0
  260.       _version        =   65536
  261.       _extentx        =   847
  262.       _extenty        =   847
  263.       _stockprops     =   0
  264.    End
  265. Attribute VB_Name = "Form1"
  266. Attribute VB_Creatable = False
  267. Attribute VB_Exposed = False
  268. Dim OldDb As DATABASE, OldWs As Workspace, DataName As String
  269. Private Sub Command1_Click()
  270.     If Len(Dir(DataName)) > 0 Then
  271.         MsgBox "File already exists", 0
  272.     Else
  273.         Set OldWs = DBEngine.Workspaces(0)
  274.         Set OldDb = OldWs.CreateDatabase(DataName, dbLangGeneral)
  275.         MsgBox "Database file " & DataName & " created.", 0
  276.         OldDb.Close
  277.     End If
  278. End Sub
  279. Private Sub Command10_Click()
  280.     'This routine reads in "Retail Item" data from an existing text file.
  281.     Dim OldDb As DATABASE, OldTbl As Recordset, OldWs As Workspace
  282.     Set OldWs = DBEngine.Workspaces(0)
  283.     Set OldDb = OldWs.OpenDatabase(DataName)
  284.     Set OldTbl = OldDb.OpenRecordset("Retail Items", dbOpenTable)
  285.     Open App.Path & "\RETAIL.TXT" For Input As #1
  286.     Do While Not EOF(1)
  287.         Input #1, itm, DESC$, price, rtprice
  288.         OldTbl.AddNew
  289.         OldTbl("Item Code") = itm
  290.         OldTbl("Item Description") = DESC$
  291.         OldTbl("Wholesale") = price
  292.         OldTbl("Retail") = rtprice
  293.         OldTbl.UPDATE
  294.     Loop
  295.     Close #1
  296.     OldTbl.Close
  297.     OldDb.Close
  298.     MsgBox "Retail Items added", 0
  299. End Sub
  300. Private Sub Command11_Click()
  301.     'This routine creates sales order information for a 30 day period.
  302.     Dim OldDb As DATABASE, OldTbl As Recordset, Tabl2 As Recordset
  303.     Dim Tabl3 As Recordset, Tabl4 As Recordset, OldWs As Workspace
  304.     Set OldWs = DBEngine.Workspaces(0)
  305.     Set OldDb = OldWs.OpenDatabase(DataName)
  306.     Set OldTbl = OldDb.OpenRecordset("Customers", dbOpenTable)
  307.     Set Tabl2 = OldDb.OpenRecordset("Orders", dbOpenTable)
  308.     Set Tabl3 = OldDb.OpenRecordset("Sales", dbOpenTable)
  309.     Set Tabl4 = OldDb.OpenRecordset("Retail Items", dbOpenTable)
  310.     OldTbl.Index = "Custno"
  311.     Tabl4.Index = "Items"
  312.     ordate = Date - 16
  313.     ordnm = 1
  314.     Picture1.Visible = True
  315.     Label2.Caption = "Processing Order"
  316.     For I = 1 To 30
  317.         nmcalls = Int(Rnd * 20 + 70)
  318.         OldWs.BeginTrans
  319.         For J = 1 To nmcalls
  320.             K = Int(Rnd * 1600) + 1
  321.             OldTbl.Seek "=", K
  322.             If Not OldTbl.NoMatch Then
  323.                 salesmn = OldTbl("SalesID")
  324.                 totsls = 0#
  325.                 L = Int(Rnd * 5) + 1
  326.                 For M = 1 To L
  327.                     itm = Int(Rnd * 100) + 1000
  328.                     iqty = Int(Rnd * 5) + 1
  329.                     Tabl3.AddNew
  330.                     Tabl3("Orderno") = ordnm
  331.                     Tabl3("Item Code") = itm
  332.                     Tabl3("Quantity") = iqty
  333.                     Tabl3.UPDATE
  334.                     Tabl4.Seek "=", itm
  335.                     If Not Tabl4.NoMatch Then
  336.                         price = Tabl4("Retail")
  337.                     Else
  338.                         price = 0#
  339.                     End If
  340.                     totsls = totsls + ordnm * price
  341.                 Next M
  342.                 Tabl2.AddNew
  343.                 Tabl2("Custno") = K
  344.                 Tabl2("SalesID") = salesmn
  345.                 Tabl2("OrderDate") = ordate
  346.                 Tabl2("Orderno") = ordnm
  347.                 Tabl2("Totcost") = totsls
  348.                 Tabl2.UPDATE
  349.             End If
  350.             ordnm = ordnm + 1
  351.         Next J
  352.         OldWs.CommitTrans
  353.         Text2.TEXT = ordnm
  354.         DoEvents
  355.         ordate = ordate + 1
  356.     Next I
  357.     Picture1.Visible = False
  358.     OldTbl.Close
  359.     Tabl2.Close
  360.     Tabl3.Close
  361.     Tabl4.Close
  362.     OldDb.Close
  363.     MsgBox Str(ordnm) + " orders processed", 0
  364. End Sub
  365. Private Sub Command12_Click()
  366.     'This routine sets up the customer number index
  367.     Dim NewTbl As TableDef, Idx1 As Index, Fld1 As Field
  368.     'Set up workspace and database
  369.     Set OldWs = DBEngine.Workspaces(0)
  370.     Set OldDb = OldWs.OpenDatabase(DataName)
  371.     'Create tabledef object
  372.     Set NewTbl = OldDb.TableDefs("Customers")
  373.     Set Idx1 = NewTbl.CREATEINDEX("Custno")
  374.     Idx1.PRIMARY = True
  375.     Set Fld1 = Idx1.CreateField("Custno")
  376.     Idx1.Fields.Append Fld1
  377.     NewTbl.Indexes.Append Idx1
  378.     OldDb.Close
  379.     MsgBox "Customer index created", 0
  380. End Sub
  381. Private Sub Command13_Click()
  382.     'This routine sets up the item code index
  383.     Dim NewTbl As TableDef, Idx1 As Index, Fld1 As Field
  384.     'Set up workspace and database
  385.     Set OldWs = DBEngine.Workspaces(0)
  386.     Set OldDb = OldWs.OpenDatabase(DataName)
  387.     'Create tabledef object
  388.     Set NewTbl = OldDb.TableDefs("Retail Items")
  389.     Set Idx1 = NewTbl.CREATEINDEX("Items")
  390.     Idx1.PRIMARY = True
  391.     Set Fld1 = Idx1.CreateField("Item Code")
  392.     Idx1.Fields.Append Fld1
  393.     NewTbl.Indexes.Append Idx1
  394.     OldDb.Close
  395.     MsgBox "Item Code index created", 0
  396. End Sub
  397. Private Sub Command14_Click()
  398.     Dim OldDb As DATABASE, OldTbl As Recordset, OldWs As Workspace
  399.     Set OldWs = DBEngine.Workspaces(0)
  400.     Set OldDb = OldWs.OpenDatabase(DataName)
  401.     Set OldTbl = OldDb.OpenRecordset("Salesmen", dbOpenTable)
  402.     OldTbl.AddNew
  403.     OldTbl("SalesLast") = "Moore"
  404.     OldTbl("SalesFirst") = "Alex"
  405.     OldTbl("SalesID") = "AMOORE"
  406.     OldTbl.UPDATE
  407.     OldTbl.AddNew
  408.     OldTbl("SalesLast") = "Dannon"
  409.     OldTbl("SalesFirst") = "Beth"
  410.     OldTbl("SalesID") = "BDANNO"
  411.     OldTbl.UPDATE
  412.     OldTbl.AddNew
  413.     OldTbl("SalesLast") = "Walsh"
  414.     OldTbl("SalesFirst") = "Bill"
  415.     OldTbl("SalesID") = "BWALSH"
  416.     OldTbl.UPDATE
  417.     OldTbl.AddNew
  418.     OldTbl("SalesLast") = "Fields"
  419.     OldTbl("SalesFirst") = "Carol"
  420.     OldTbl("SalesID") = "CFIELD"
  421.     OldTbl.UPDATE
  422.     OldTbl.AddNew
  423.     OldTbl("SalesLast") = "Green"
  424.     OldTbl("SalesFirst") = "Elizabeth"
  425.     OldTbl("SalesID") = "EGREEN"
  426.     OldTbl.UPDATE
  427.     OldTbl.AddNew
  428.     OldTbl("SalesLast") = "Burns"
  429.     OldTbl("SalesFirst") = "John"
  430.     OldTbl("SalesID") = "JBURNS"
  431.     OldTbl.UPDATE
  432.     OldTbl.AddNew
  433.     OldTbl("SalesLast") = "Thomas"
  434.     OldTbl("SalesFirst") = "Jim"
  435.     OldTbl("SalesID") = "JTHOMA"
  436.     OldTbl.UPDATE
  437.     OldTbl.AddNew
  438.     OldTbl("SalesLast") = "Miller"
  439.     OldTbl("SalesFirst") = "Karen"
  440.     OldTbl("SalesID") = "KMILLE"
  441.     OldTbl.UPDATE
  442.     OldTbl.AddNew
  443.     OldTbl("SalesLast") = "Evans"
  444.     OldTbl("SalesFirst") = "Lisa"
  445.     OldTbl("SalesID") = "LEVANS"
  446.     OldTbl.UPDATE
  447.     OldTbl.AddNew
  448.     OldTbl("SalesLast") = "Adams"
  449.     OldTbl("SalesFirst") = "Max"
  450.     OldTbl("SalesID") = "MADAMS"
  451.     OldTbl.UPDATE
  452.     OldTbl.AddNew
  453.     OldTbl("SalesLast") = "Johnson"
  454.     OldTbl("SalesFirst") = "Mary"
  455.     OldTbl("SalesID") = "MJOHNS"
  456.     OldTbl.UPDATE
  457.     OldTbl.AddNew
  458.     OldTbl("SalesLast") = "Norton"
  459.     OldTbl("SalesFirst") = "Mike"
  460.     OldTbl("SalesID") = "MNORTO"
  461.     OldTbl.UPDATE
  462.     OldTbl.AddNew
  463.     OldTbl("SalesLast") = "Smith"
  464.     OldTbl("SalesFirst") = "Robyn"
  465.     OldTbl("SalesID") = "RSMITH"
  466.     OldTbl.UPDATE
  467.     OldTbl.AddNew
  468.     OldTbl("SalesLast") = "Reid"
  469.     OldTbl("SalesFirst") = "Sam"
  470.     OldTbl("SalesID") = "SREID"
  471.     OldTbl.UPDATE
  472.     OldTbl.AddNew
  473.     OldTbl("SalesLast") = "Jackson"
  474.     OldTbl("SalesFirst") = "Tim"
  475.     OldTbl("SalesID") = "TJACKS"
  476.     OldTbl.UPDATE
  477.     OldTbl.Close
  478.     OldDb.Close
  479.     MsgBox "Salesmen data added", 0
  480. End Sub
  481. Private Sub Command2_Click()
  482.     GetFile.Filter = "Database Files (*.MDB)|*.mdb|All Files|*.*"
  483.     GetFile.DefaultExt = "MDB"
  484.     GetFile.ShowOpen
  485.     DataName = GetFile.filename
  486.     Text1.TEXT = DataName
  487. End Sub
  488. Private Sub Command3_Click()
  489.     ' This routine uses the old VB3 methods to create the Salesmen table
  490.     Dim NewTbl As New TableDef, NewDb As DATABASE
  491.     Set NewDb = OpenDatabase(DataName)
  492.     NewTbl.Name = "Salesmen"
  493.     Dim F1 As New Field, F2 As New Field, F3 As New Field
  494.     F1.Name = "SalesID"
  495.     F1.Type = dbText
  496.     F1.Size = 6
  497.     F2.Name = "SalesLast"
  498.     F2.Type = dbText
  499.     F2.Size = 30
  500.     F3.Name = "SalesFirst"
  501.     F3.Type = dbText
  502.     F3.Size = 30
  503.     NewTbl.Fields.Append F1
  504.     NewTbl.Fields.Append F2
  505.     NewTbl.Fields.Append F3
  506.     NewDb.TableDefs.Append NewTbl
  507.     MsgBox "Salesmen table was created", 0
  508.     NewDb.Close
  509. End Sub
  510. Private Sub Command4_Click()
  511.     'This routine creates the Customers table using the CreateFields method
  512.     '  with the optional arguments specified.
  513.     'Dimension data access objects
  514.     Dim NewTbl As TableDef, F1 As Field, F2 As Field, F3 As Field, F4 As Field
  515.     Dim F5 As Field, F6 As Field, F7 As Field, F8 As Field
  516.     Dim F9 As Field, F10 As Field
  517.     'Set up workspace and database
  518.     Set OldWs = DBEngine.Workspaces(0)
  519.     Set OldDb = OldWs.OpenDatabase(DataName)
  520.     'Create tabledef object
  521.     Set NewTbl = OldDb.CreateTableDef("Customers")
  522.     'Create field objects
  523.     Set F1 = NewTbl.CreateField("Custno", dbLong)
  524.     F1.Attributes = dbAutoIncrField
  525.     Set F2 = NewTbl.CreateField("Lastname", dbText, 30)
  526.     Set F3 = NewTbl.CreateField("Firstname", dbText, 30)
  527.     Set F4 = NewTbl.CreateField("Address", dbText, 40)
  528.     Set F5 = NewTbl.CreateField("City", dbText, 30)
  529.     Set F6 = NewTbl.CreateField("State", dbText, 2)
  530.     Set F7 = NewTbl.CreateField("Zip", dbText, 5)
  531.     Set F8 = NewTbl.CreateField("Phone", dbText, 13)
  532.     Set F9 = NewTbl.CreateField("Interests", dbMemo)
  533.     Set F10 = NewTbl.CreateField("SalesID", dbText, 6)
  534.     'Add fields to tabledef
  535.     NewTbl.Fields.Append F1
  536.     NewTbl.Fields.Append F2
  537.     NewTbl.Fields.Append F3
  538.     NewTbl.Fields.Append F4
  539.     NewTbl.Fields.Append F5
  540.     NewTbl.Fields.Append F6
  541.     NewTbl.Fields.Append F7
  542.     NewTbl.Fields.Append F8
  543.     NewTbl.Fields.Append F9
  544.     NewTbl.Fields.Append F10
  545.     'Add tabledef to database
  546.     OldDb.TableDefs.Append NewTbl
  547.     OldDb.Close
  548.     MsgBox "Customers table created", 0
  549. End Sub
  550. Private Sub Command5_Click()
  551.     'This routine creates the Retail Items table using the CreateFields method
  552.     '  without the optional arguments specified.  All field properties are
  553.     '  explicitly set.
  554.     'Dimension data access objects
  555.     Dim NewTbl As TableDef, Fld(1 To 9) As Field
  556.     'Set up workspace and database
  557.     Set OldWs = DBEngine.Workspaces(0)
  558.     Set OldDb = OldWs.OpenDatabase(DataName)
  559.     'Create tabledef object
  560.     Set NewTbl = OldDb.CreateTableDef("Retail Items")
  561.     NewTbl.ValidationRule = "[Retail] > [Wholesale]"
  562.     NewTbl.ValidationText = "Retail price must exceed wholesale price."
  563.     'Create field objects
  564.     For I = 1 To 9
  565.         Set Fld(I) = NewTbl.CreateField()
  566.     Next I
  567.     Fld(1).Name = "Item Code"
  568.     Fld(1).Type = dbInteger
  569.     Fld(2).Name = "Item Description"
  570.     Fld(2).Type = dbText
  571.     Fld(2).Size = 50
  572.     Fld(3).Name = "Product Category"
  573.     Fld(3).Type = dbText
  574.     Fld(3).Size = 10
  575.     Fld(4).Name = "Wholesale"
  576.     Fld(4).Type = dbSingle
  577.     Fld(4).ValidationRule = "[Wholesale] > 0"
  578.     Fld(4).ValidationText = "Wholesale price must be greater than 0."
  579.     Fld(5).Name = "Retail"
  580.     Fld(5).Type = dbSingle
  581.     Fld(6).Name = "Min Quantity"
  582.     Fld(6).Type = dbInteger
  583.     Fld(7).Name = "OnHand"
  584.     Fld(7).Type = dbInteger
  585.     Fld(8).Name = "SupplierID"
  586.     Fld(8).Type = dbLong
  587.     Fld(9).Name = "Photo"
  588.     Fld(9).Type = dbLongBinary
  589.     'Add fields to tabledef
  590.     For I = 1 To 9
  591.         NewTbl.Fields.Append Fld(I)
  592.     Next I
  593.     'Add tabledef to database
  594.     OldDb.TableDefs.Append NewTbl
  595.     OldDb.Close
  596.     MsgBox "Retail Items table created", 0
  597. End Sub
  598. Private Sub Command6_Click()
  599.     'This routine creates the Orders table using a DDL query.
  600.     'Set up workspace and database
  601.     Set OldWs = DBEngine.Workspaces(0)
  602.     Set OldDb = OldWs.OpenDatabase(DataName)
  603.     SQLCreate = "CREATE TABLE Orders (Orderno INTEGER, Custno LONG, SalesID TEXT (6), OrderDate DATE, Totcost SINGLE)"
  604.     OldDb.Execute SQLCreate
  605.     OldDb.Close
  606.     MsgBox "Orders table has been created.", 0
  607. End Sub
  608. Private Sub Command7_Click()
  609.     Set OldWs = DBEngine.Workspaces(0)
  610.     Set OldDb = OldWs.OpenDatabase(DataName)
  611.     SQLCreate = "CREATE TABLE Sales (Orderno INTEGER, [Item Code] INTEGER, "
  612.     SQLCreate = SQLCreate + "Quantity INTEGER)"
  613.     OldDb.Execute SQLCreate
  614.     SQLCreate = "CREATE TABLE Suppliers (SupplierID LONG, Name TEXT (50), "
  615.     SQLCreate = SQLCreate + "Contact TEXT (50), Address TEXT (50), City "
  616.     SQLCreate = SQLCreate + "TEXT (30), State TEXT (2), Zip TEXT (5), "
  617.     SQLCreate = SQLCreate + "Phone TEXT (13))"
  618.     OldDb.Execute SQLCreate
  619.     OldDb.Close
  620.     MsgBox "Other tables have been created.", 0
  621. End Sub
  622. Private Sub Command8_Click()
  623.     'This routine creates 1600 customer records for the Customers table.
  624.     ReDim fname$(1 To 40), lname$(1 To 40), city2$(1 To 100)
  625.     ReDim stateID$(1 To 100), stzip$(1 To 100), starea$(1 To 100)
  626.     ReDim street$(1 To 40)
  627.     Dim OldDb As DATABASE, OldTbl As Recordset
  628.     fname$(1) = "Alice"
  629.     fname$(2) = "Andrew"
  630.     fname$(3) = "Betty"
  631.     fname$(4) = "Bill"
  632.     fname$(5) = "Charles"
  633.     fname$(6) = "Debra"
  634.     fname$(7) = "Don"
  635.     fname$(8) = "Erin"
  636.     fname$(9) = "Eric"
  637.     fname$(10) = "Faye"
  638.     fname$(11) = "Frank"
  639.     fname$(12) = "Gail"
  640.     fname$(13) = "Greg"
  641.     fname$(14) = "Helen"
  642.     fname$(15) = "Henry"
  643.     fname$(16) = "Janice"
  644.     fname$(17) = "John"
  645.     fname$(18) = "Karen"
  646.     fname$(19) = "Laura"
  647.     fname$(20) = "Larry"
  648.     fname$(21) = "Michele"
  649.     fname$(22) = "Michael"
  650.     fname$(23) = "Nancy"
  651.     fname$(24) = "Nick"
  652.     fname$(25) = "Paula"
  653.     fname$(26) = "Pete"
  654.     fname$(27) = "Rhonda"
  655.     fname$(28) = "Richard"
  656.     fname$(29) = "Sally"
  657.     fname$(30) = "Sam"
  658.     fname$(31) = "Scott"
  659.     fname$(32) = "Terry"
  660.     fname$(33) = "Thomas"
  661.     fname$(34) = "Vicky"
  662.     fname$(35) = "Wanda"
  663.     fname$(36) = "Lisa"
  664.     fname$(37) = "Elizabeth"
  665.     fname$(38) = "Doug"
  666.     fname$(39) = "Bruce"
  667.     fname$(40) = "Pam"
  668.     lname$(1) = "Andrews"
  669.     lname$(2) = "Brown"
  670.     lname$(3) = "Casey"
  671.     lname$(4) = "Davis"
  672.     lname$(5) = "Fleming"
  673.     lname$(6) = "Gray"
  674.     lname$(7) = "Hancock"
  675.     lname$(8) = "James"
  676.     lname$(9) = "Kirk"
  677.     lname$(10) = "Lewis"
  678.     lname$(11) = "Moore"
  679.     lname$(12) = "Monroe"
  680.     lname$(13) = "Nelson"
  681.     lname$(14) = "O'Toole"
  682.     lname$(15) = "Richards"
  683.     lname$(16) = "Scott"
  684.     lname$(17) = "Thompson"
  685.     lname$(18) = "Vincent"
  686.     lname$(19) = "Walters"
  687.     lname$(20) = "Young"
  688.     lname$(21) = "Adams"
  689.     lname$(22) = "Black"
  690.     lname$(23) = "Coleman"
  691.     lname$(24) = "Douglas"
  692.     lname$(25) = "Evans"
  693.     lname$(26) = "Fontaine"
  694.     lname$(27) = "Green"
  695.     lname$(28) = "Hawthorne"
  696.     lname$(29) = "Johnson"
  697.     lname$(30) = "Long"
  698.     lname$(31) = "Maxwell"
  699.     lname$(32) = "Nichols"
  700.     lname$(33) = "Owens"
  701.     lname$(34) = "Roberts"
  702.     lname$(35) = "Smith"
  703.     lname$(36) = "Taylor"
  704.     lname$(37) = "Vaughn"
  705.     lname$(38) = "White"
  706.     lname$(39) = "Polk"
  707.     lname$(40) = "Jackson"
  708.     street$(1) = "Main Street"
  709.     street$(2) = "Government Street"
  710.     street$(3) = "Brook Lane"
  711.     street$(4) = "Meadow Drive"
  712.     street$(5) = "Jefferson Road"
  713.     street$(6) = "Montgomery Highway"
  714.     street$(7) = "Happy Trail"
  715.     street$(8) = "J Street"
  716.     street$(9) = "1st Avenue"
  717.     street$(10) = "Berkley Drive"
  718.     street$(11) = "Bayou Boulevard"
  719.     street$(12) = "Morris Avenue"
  720.     street$(13) = "Old Mill Road"
  721.     street$(14) = "Langley"
  722.     street$(15) = "Valley Road"
  723.     street$(16) = "Strawberry Lane"
  724.     street$(17) = "Lexington Way"
  725.     street$(18) = "Archer Road"
  726.     street$(19) = "Panorama Trace"
  727.     street$(20) = "Skyview Lane"
  728.     street$(21) = "Water Oak Drive"
  729.     street$(22) = "Burning Tree Road"
  730.     street$(23) = "East Ridge Circle"
  731.     street$(24) = "Hillcrest Drive"
  732.     street$(25) = "Sherwood Forest"
  733.     street$(26) = "Seaview Drive"
  734.     street$(27) = "Crabb Lane"
  735.     street$(28) = "Canterbury Trails"
  736.     street$(29) = "Native Dancer Drive"
  737.     street$(30) = "Beacon Hill Road"
  738.     street$(31) = "River Bend"
  739.     street$(32) = "Sandy Springs Road"
  740.     street$(33) = "Lookout Drive"
  741.     street$(34) = "Hurricane Way"
  742.     street$(35) = "Shifting Sands Trail"
  743.     street$(36) = "English Knoll"
  744.     street$(37) = "Wilderness Trail"
  745.     street$(38) = "Yorkshire Place"
  746.     street$(39) = "Lost Your Way"
  747.     street$(40) = "Hidden Valley Lane"
  748.     city2$(1) = "Little Rock"
  749.     stateID$(1) = "AR"
  750.     stzip$(1) = "72203"
  751.     starea$(1) = "501"
  752.     city2$(2) = "Birmingham"
  753.     stateID$(2) = "AL"
  754.     stzip$(2) = "35203"
  755.     starea$(2) = "205"
  756.     city2$(3) = "Mobile"
  757.     stateID$(3) = "AL"
  758.     stzip$(3) = "36608"
  759.     starea$(3) = "205"
  760.     city2$(4) = "Juneau"
  761.     stateID$(4) = "AK"
  762.     stzip$(4) = "99802"
  763.     starea$(4) = "907"
  764.     city2$(5) = "Fairbanks"
  765.     stateID$(5) = "AK"
  766.     stzip$(5) = "99709"
  767.     starea$(5) = "907"
  768.     city2$(6) = "Phoenix"
  769.     stateID$(6) = "AZ"
  770.     stzip$(6) = "85021"
  771.     starea$(6) = "602"
  772.     city2$(7) = "Tuscon"
  773.     stateID$(7) = "AZ"
  774.     stzip$(7) = "85715"
  775.     starea$(7) = "602"
  776.     city2$(8) = "San Francisco"
  777.     stateID$(8) = "CA"
  778.     stzip$(8) = "94105"
  779.     starea$(8) = "415"
  780.     city2$(9) = "Los Angeles"
  781.     stateID$(9) = "CA"
  782.     stzip$(9) = "90036"
  783.     starea$(9) = "213"
  784.     city2$(10) = "Denver"
  785.     stateID$(10) = "CO"
  786.     stzip$(10) = "80226"
  787.     starea$(10) = "303"
  788.     city2$(11) = "Boulder"
  789.     stateID$(11) = "CO"
  790.     stzip$(11) = "80303"
  791.     starea$(11) = "303"
  792.     city2$(12) = "Wilmington"
  793.     stateID$(12) = "DE"
  794.     stzip$(12) = "72203"
  795.     starea$(12) = "501"
  796.     city2$(13) = "Orlando"
  797.     stateID$(13) = "FL"
  798.     stzip$(13) = "32804"
  799.     starea$(13) = "407"
  800.     city2$(14) = "Jacksonville"
  801.     stateID$(14) = "FL"
  802.     stzip$(14) = "32257"
  803.     starea$(14) = "904"
  804.     city2$(15) = "Miami"
  805.     stateID$(15) = "FL"
  806.     stzip$(15) = "33162"
  807.     starea$(15) = "305"
  808.     city2$(16) = "Atlanta"
  809.     stateID$(16) = "GA"
  810.     stzip$(16) = "30314"
  811.     starea$(16) = "404"
  812.     city2$(17) = "Augusta"
  813.     stateID$(17) = "GA"
  814.     stzip$(17) = "30904"
  815.     starea$(17) = "706"
  816.     city2$(18) = "Honolulu"
  817.     stateID$(18) = "HI"
  818.     stzip$(18) = "96817"
  819.     starea$(18) = "808"
  820.     city2$(19) = "Hilo"
  821.     stateID$(19) = "HI"
  822.     stzip$(19) = "96721"
  823.     starea$(19) = "808"
  824.     city2$(20) = "Boise"
  825.     stateID$(20) = "ID"
  826.     stzip$(20) = "83709"
  827.     starea$(20) = "208"
  828.     city2$(21) = "Hartford"
  829.     stateID$(21) = "CT"
  830.     stzip$(21) = "06117"
  831.     starea$(21) = "203"
  832.     city2$(22) = "Chicago"
  833.     stateID$(22) = "IL"
  834.     stzip$(22) = "60639"
  835.     starea$(22) = "312"
  836.     city2$(23) = "Peoria"
  837.     stateID$(23) = "IL"
  838.     stzip$(23) = "61605"
  839.     starea$(23) = "309"
  840.     city2$(24) = "Indianapolis"
  841.     stateID$(24) = "IN"
  842.     stzip$(24) = "46209"
  843.     starea$(24) = "317"
  844.     city2$(25) = "Fort Wayne"
  845.     stateID$(25) = "IN"
  846.     stzip$(25) = "46835"
  847.     starea$(25) = "317"
  848.     city2$(26) = "Des Moines"
  849.     stateID$(26) = "IA"
  850.     stzip$(26) = "50317"
  851.     starea$(26) = "515"
  852.     city2$(27) = "Cedar Rapids"
  853.     stateID$(27) = "IA"
  854.     stzip$(27) = "52402"
  855.     starea$(27) = "515"
  856.     city2$(28) = "Wichita"
  857.     stateID$(28) = "KS"
  858.     stzip$(28) = "67219"
  859.     starea$(28) = "316"
  860.     city2$(29) = "Topeka"
  861.     stateID$(29) = "KS"
  862.     stzip$(29) = "66614"
  863.     starea$(29) = "913"
  864.     city2$(30) = "Lexington"
  865.     stateID$(30) = "KY"
  866.     stzip$(30) = "40502"
  867.     starea$(30) = "606"
  868.     city2$(31) = "New Orleans"
  869.     stateID$(31) = "LA"
  870.     stzip$(31) = "70122"
  871.     starea$(31) = "504"
  872.     city2$(32) = "Shreveport"
  873.     stateID$(32) = "LA"
  874.     stzip$(32) = "71118"
  875.     starea$(32) = "318"
  876.     city2$(33) = "Portland"
  877.     stateID$(33) = "ME"
  878.     stzip$(33) = "04106"
  879.     starea$(33) = "207"
  880.     city2$(34) = "Bangor"
  881.     stateID$(34) = "ME"
  882.     stzip$(34) = "04401"
  883.     starea$(34) = "207"
  884.     city2$(35) = "Baltimore"
  885.     stateID$(35) = "MD"
  886.     stzip$(35) = "21204"
  887.     starea$(35) = "410"
  888.     city2$(36) = "Washington"
  889.     stateID$(36) = "DC"
  890.     stzip$(36) = "20215"
  891.     starea$(36) = "202"
  892.     city2$(37) = "Boston"
  893.     stateID$(37) = "MA"
  894.     stzip$(37) = "02166"
  895.     starea$(37) = "617"
  896.     city2$(38) = "Springfield"
  897.     stateID$(38) = "MA"
  898.     stzip$(38) = "01119"
  899.     starea$(38) = "413"
  900.     city2$(39) = "Detroit"
  901.     stateID$(39) = "MI"
  902.     stzip$(39) = "48214"
  903.     starea$(39) = "313"
  904.     city2$(40) = "Lansing"
  905.     stateID$(40) = "MI"
  906.     stzip$(40) = "48906"
  907.     starea$(40) = "517"
  908.     city2$(41) = "Minneapolis"
  909.     stateID$(41) = "MN"
  910.     stzip$(41) = "55446"
  911.     starea$(41) = "612"
  912.     city2$(42) = "St. Paul"
  913.     stateID$(42) = "MN"
  914.     stzip$(42) = "55109"
  915.     starea$(42) = "612"
  916.     city2$(43) = "Jackson"
  917.     stateID$(43) = "MS"
  918.     stzip$(43) = "39208"
  919.     starea$(43) = "601"
  920.     city2$(44) = "Gulfport"
  921.     stateID$(44) = "MS"
  922.     stzip$(44) = "39507"
  923.     starea$(44) = "601"
  924.     city2$(45) = "St. Louis"
  925.     stateID$(45) = "MO"
  926.     stzip$(45) = "63146"
  927.     starea$(45) = "314"
  928.     city2$(46) = "Kansas City"
  929.     stateID$(46) = "MO"
  930.     stzip$(46) = "64132"
  931.     starea$(46) = "816"
  932.     city2$(47) = "Billings"
  933.     stateID$(47) = "MT"
  934.     stzip$(47) = "59101"
  935.     starea$(47) = "406"
  936.     city2$(48) = "Omaha"
  937.     stateID$(48) = "NE"
  938.     stzip$(48) = "68154"
  939.     starea$(48) = "402"
  940.     city2$(49) = "Lincoln"
  941.     stateID$(49) = "NE"
  942.     stzip$(49) = "68502"
  943.     starea$(49) = "402"
  944.     city2$(50) = "Las Vegas"
  945.     stateID$(50) = "NV"
  946.     stzip$(50) = "89110"
  947.     starea$(50) = "702"
  948.     city2$(51) = "Reno"
  949.     stateID$(51) = "NV"
  950.     stzip$(51) = "89520"
  951.     starea$(51) = "702"
  952.     city2$(52) = "Portsmouth"
  953.     stateID$(52) = "NH"
  954.     stzip$(52) = "03801"
  955.     starea$(52) = "603"
  956.     city2$(53) = "Newark"
  957.     stateID$(53) = "NJ"
  958.     stzip$(53) = "07105"
  959.     starea$(53) = "201"
  960.     city2$(54) = "Trenton"
  961.     stateID$(54) = "NJ"
  962.     stzip$(54) = "08618"
  963.     starea$(54) = "609"
  964.     city2$(55) = "New York City"
  965.     stateID$(55) = "NY"
  966.     stzip$(55) = "10023"
  967.     starea$(55) = "212"
  968.     city2$(56) = "Rochester"
  969.     stateID$(56) = "NY"
  970.     stzip$(56) = "14608"
  971.     starea$(56) = "716"
  972.     city2$(57) = "Buffalo"
  973.     stateID$(57) = "NY"
  974.     stzip$(57) = "14201"
  975.     starea$(57) = "716"
  976.     city2$(58) = "Syracuse"
  977.     stateID$(58) = "NY"
  978.     stzip$(58) = "13210"
  979.     starea$(58) = "315"
  980.     city2$(59) = "Albuquerque"
  981.     stateID$(59) = "NM"
  982.     stzip$(59) = "87113"
  983.     starea$(59) = "505"
  984.     city2$(60) = "Santa Fe"
  985.     stateID$(60) = "NM"
  986.     stzip$(60) = "87505"
  987.     starea$(60) = "505"
  988.     city2$(61) = "Bismark"
  989.     stateID$(61) = "ND"
  990.     stzip$(61) = "58501"
  991.     starea$(61) = "701"
  992.     city2$(62) = "Charlotte"
  993.     stateID$(62) = "NC"
  994.     stzip$(62) = "28209"
  995.     starea$(62) = "704"
  996.     city2$(63) = "Raleigh"
  997.     stateID$(63) = "NC"
  998.     stzip$(63) = "27612"
  999.     starea$(63) = "919"
  1000.     city2$(64) = "Cleveland"
  1001.     stateID$(64) = "OH"
  1002.     stzip$(64) = "44111"
  1003.     starea$(64) = "216"
  1004.     city2$(65) = "Cincinnati"
  1005.     stateID$(65) = "OH"
  1006.     stzip$(65) = "45255"
  1007.     starea$(65) = "513"
  1008.     city2$(66) = "Toledo"
  1009.     stateID$(66) = "OH"
  1010.     stzip$(66) = "43623"
  1011.     starea$(66) = "419"
  1012.     city2$(67) = "Oklahoma City"
  1013.     stateID$(67) = "OK"
  1014.     stzip$(67) = "73130"
  1015.     starea$(67) = "405"
  1016.     city2$(68) = "Tulsa"
  1017.     stateID$(68) = "OK"
  1018.     stzip$(68) = "74128"
  1019.     starea$(68) = "918"
  1020.     city2$(69) = "Portland"
  1021.     stateID$(69) = "OR"
  1022.     stzip$(69) = "97267"
  1023.     starea$(69) = "503"
  1024.     city2$(70) = "Pittsburgh"
  1025.     stateID$(70) = "PA"
  1026.     stzip$(70) = "15229"
  1027.     starea$(70) = "412"
  1028.     city2$(71) = "Philadelphia"
  1029.     stateID$(71) = "PA"
  1030.     stzip$(71) = "19139"
  1031.     starea$(71) = "215"
  1032.     city2$(72) = "Columbia"
  1033.     stateID$(72) = "SC"
  1034.     stzip$(72) = "29204"
  1035.     starea$(72) = "803"
  1036.     city2$(73) = "Charleston"
  1037.     stateID$(73) = "SC"
  1038.     stzip$(73) = "29407"
  1039.     starea$(73) = "803"
  1040.     city2$(74) = "Sioux Falls"
  1041.     stateID$(74) = "SD"
  1042.     stzip$(74) = "57106"
  1043.     starea$(74) = "605"
  1044.     city2$(75) = "Nashville"
  1045.     stateID$(75) = "TN"
  1046.     stzip$(75) = "37209"
  1047.     starea$(75) = "901"
  1048.     city2$(76) = "Knoxville"
  1049.     stateID$(76) = "TN"
  1050.     stzip$(76) = "37917"
  1051.     starea$(76) = "615"
  1052.     city2$(77) = "Chattanooga"
  1053.     stateID$(77) = "TN"
  1054.     stzip$(77) = "37411"
  1055.     starea$(77) = "615"
  1056.     city2$(78) = "Dallas"
  1057.     stateID$(78) = "TX"
  1058.     stzip$(78) = "75229"
  1059.     starea$(78) = "214"
  1060.     city2$(79) = "Houston"
  1061.     stateID$(79) = "TX"
  1062.     stzip$(79) = "77026"
  1063.     starea$(79) = "713"
  1064.     city2$(80) = "Austin"
  1065.     stateID$(80) = "TX"
  1066.     stzip$(80) = "78748"
  1067.     starea$(80) = "512"
  1068.     city2$(81) = "Salt Lake City"
  1069.     stateID$(81) = "UT"
  1070.     stzip$(81) = "84121"
  1071.     starea$(81) = "801"
  1072.     city2$(82) = "Provo"
  1073.     stateID$(82) = "UT"
  1074.     stzip$(82) = "84604"
  1075.     starea$(82) = "801"
  1076.     city2$(83) = "Richmond"
  1077.     stateID$(83) = "VA"
  1078.     stzip$(83) = "23236"
  1079.     starea$(83) = "804"
  1080.     city2$(84) = "Williamsburg"
  1081.     stateID$(84) = "VA"
  1082.     stzip$(84) = "23185"
  1083.     starea$(84) = "804"
  1084.     city2$(85) = "Wheeling"
  1085.     stateID$(85) = "WV"
  1086.     stzip$(85) = "26003"
  1087.     starea$(85) = "304"
  1088.     city2$(86) = "Seattle"
  1089.     stateID$(86) = "WA"
  1090.     stzip$(86) = "98103"
  1091.     starea$(86) = "206"
  1092.     city2$(87) = "Spokane"
  1093.     stateID$(87) = "WA"
  1094.     stzip$(87) = "99204"
  1095.     starea$(87) = "509"
  1096.     city2$(88) = "Milwaukee"
  1097.     stateID$(88) = "WI"
  1098.     stzip$(88) = "53216"
  1099.     starea$(88) = "414"
  1100.     city2$(89) = "Green Bay"
  1101.     stateID$(89) = "WI"
  1102.     stzip$(89) = "54313"
  1103.     starea$(89) = "414"
  1104.     city2$(90) = "Cheyenne"
  1105.     stateID$(90) = "WY"
  1106.     stzip$(90) = "82009"
  1107.     starea$(90) = "307"
  1108.     city2$(91) = "Casper"
  1109.     stateID$(91) = "WY"
  1110.     stzip$(91) = "82601"
  1111.     starea$(91) = "307"
  1112.     city2$(92) = "Tampa"
  1113.     stateID$(92) = "FL"
  1114.     stzip$(92) = "33629"
  1115.     starea$(92) = "813"
  1116.     city2$(93) = "Huntsville"
  1117.     stateID$(93) = "AL"
  1118.     stzip$(93) = "35802"
  1119.     starea$(93) = "205"
  1120.     city2$(94) = "Savannah"
  1121.     stateID$(94) = "GA"
  1122.     stzip$(94) = "31406"
  1123.     starea$(94) = "912"
  1124.     city2$(95) = "San Antonio"
  1125.     stateID$(95) = "TX"
  1126.     stzip$(95) = "78223"
  1127.     starea$(95) = "512"
  1128.     city2$(96) = "San Diego"
  1129.     stateID$(96) = "CA"
  1130.     stzip$(96) = "92103"
  1131.     starea$(96) = "619"
  1132.     city2$(97) = "Sacramento"
  1133.     stateID$(97) = "CA"
  1134.     stzip$(97) = "95842"
  1135.     starea$(97) = "916"
  1136.     city2$(98) = "Pensacola"
  1137.     stateID$(98) = "FL"
  1138.     stzip$(98) = "32503"
  1139.     starea$(98) = "904"
  1140.     city2$(99) = "Baton Rouge"
  1141.     stateID$(99) = "LA"
  1142.     stzip$(99) = "70814"
  1143.     starea$(99) = "504"
  1144.     city2$(100) = "Burlington"
  1145.     stateID$(100) = "VT"
  1146.     stzip$(100) = "05401"
  1147.     starea$(100) = "802"
  1148.     Set OldWs = DBEngine.Workspaces(0)
  1149.     Set OldDb = OldWs.OpenDatabase(DataName)
  1150.     Set OldTbl = OldDb.OpenRecordset("Customers", dbOpenTable)
  1151.     Picture1.Visible = True
  1152.     For I = 1 To 40
  1153.         OldWs.BeginTrans
  1154.         For J = 1 To 40
  1155.            K2 = (I - 1) * 40 + J
  1156.            Text2.TEXT = Str(K2) & "of 1600"
  1157.            K = (K2 Mod 100) + 1
  1158.            L = 1 + Int(40 * Rnd())
  1159.            M = 1 + Int(9999 * Rnd())
  1160.            N = 1000 + Int(8999 * Rnd())
  1161.            OldTbl.AddNew
  1162.            OldTbl("Lastname") = lname$(I)
  1163.            OldTbl("Firstname") = fname$(J)
  1164.            OldTbl("City") = city2$(K)
  1165.            OldTbl("State") = stateID$(K)
  1166.            OldTbl("Zip") = stzip$(K)
  1167.            OldTbl("Address") = Str(M) & " " & street$(L)
  1168.            OldTbl("Phone") = "(" & starea$(K) & ")555-" & Right(Str(N), 4)
  1169.            OldTbl.UPDATE
  1170.         Next J
  1171.         OldWs.CommitTrans
  1172.         DoEvents
  1173.     Next I
  1174.     Picture1.Visible = False
  1175.     MsgBox "All data loaded", 0
  1176.     OldTbl.Close
  1177.     OldDb.Close
  1178. End Sub
  1179. Private Sub Command9_Click()
  1180.     ReDim sales$(1 To 15)
  1181.     Dim OldDb As DATABASE, OldTbl As Recordset, OldWs As Workspace
  1182.     Set OldWs = DBEngine.Workspaces(0)
  1183.     Set OldDb = OldWs.OpenDatabase(DataName)
  1184.     Set OldTbl = OldDb.OpenRecordset("Salesmen", dbOpenTable)
  1185.     OldTbl.MoveFirst
  1186.     For I = 1 To 15
  1187.         sales$(I) = OldTbl("SalesID")
  1188.         OldTbl.MoveNext
  1189.     Next I
  1190.     OldTbl.Close
  1191.     Set OldTbl = OldDb.OpenRecordset("Customers", dbOpenTable)
  1192.     OldTbl.MoveFirst
  1193.     J = 1
  1194.     Do Until OldTbl.EOF
  1195.         J = J + 1
  1196.         If J > 15 Then
  1197.             J = 1
  1198.         End If
  1199.         OldTbl.Edit
  1200.         OldTbl("SalesID") = sales$(J)
  1201.         OldTbl.UPDATE
  1202.         OldTbl.MoveNext
  1203.     Loop
  1204.     OldTbl.Close
  1205.     OldDb.Close
  1206.     MsgBox "Sales IDs added", 0
  1207. End Sub
  1208. Private Sub Form_Activate()
  1209.     GetFile.Filter = "Database Files (*.MDB)|*.mdb|All Files|*.*"
  1210.     GetFile.DefaultExt = "MDB"
  1211.     GetFile.ShowOpen
  1212.     DataName = GetFile.filename
  1213.     Text1.TEXT = DataName
  1214. End Sub
  1215.