home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / fox_adr / adr_form.frm < prev    next >
Text File  |  1993-08-26  |  20KB  |  880 lines

  1. VERSION 2.00
  2. Begin Form adr_form 
  3.    Caption         =   "Address Book"
  4.    ClientHeight    =   6240
  5.    ClientLeft      =   2145
  6.    ClientTop       =   2250
  7.    ClientWidth     =   8880
  8.    Height          =   6645
  9.    Icon            =   ADR_FORM.FRX:0000
  10.    Left            =   2085
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   6240
  13.    ScaleWidth      =   8880
  14.    Top             =   1905
  15.    Width           =   9000
  16.    Begin CommandButton last_but 
  17.       Caption         =   "Las&t"
  18.       Height          =   495
  19.       Left            =   2580
  20.       TabIndex        =   33
  21.       Top             =   5640
  22.       Width           =   675
  23.    End
  24.    Begin CommandButton first_but 
  25.       Caption         =   "F&irst"
  26.       Height          =   495
  27.       Left            =   240
  28.       TabIndex        =   32
  29.       Top             =   5640
  30.       Width           =   675
  31.    End
  32.    Begin CommandButton list_but 
  33.       Caption         =   "&List"
  34.       Height          =   495
  35.       Left            =   4140
  36.       TabIndex        =   28
  37.       Top             =   5640
  38.       Width           =   675
  39.    End
  40.    Begin CheckBox Action_needed 
  41.       Caption         =   "&Action needed"
  42.       Height          =   255
  43.       Left            =   1500
  44.       TabIndex        =   27
  45.       Top             =   780
  46.       Width           =   1635
  47.    End
  48.    Begin CheckBox action_check 
  49.       Caption         =   "S&how outstanding action only"
  50.       Height          =   375
  51.       Left            =   240
  52.       TabIndex        =   26
  53.       Top             =   5160
  54.       Width           =   2835
  55.    End
  56.    Begin OptionButton order_option 
  57.       Caption         =   "Post &code"
  58.       Height          =   375
  59.       Index           =   0
  60.       Left            =   180
  61.       TabIndex        =   24
  62.       Top             =   4620
  63.       Width           =   1215
  64.    End
  65.    Begin OptionButton order_option 
  66.       Caption         =   "S&urname"
  67.       Height          =   375
  68.       Index           =   1
  69.       Left            =   180
  70.       TabIndex        =   23
  71.       Top             =   4260
  72.       Width           =   1215
  73.    End
  74.    Begin CommandButton pack_but 
  75.       Caption         =   "Pac&k"
  76.       Height          =   495
  77.       Left            =   6480
  78.       TabIndex        =   21
  79.       Top             =   5640
  80.       Width           =   675
  81.    End
  82.    Begin CommandButton del_but 
  83.       Caption         =   "&Delete"
  84.       Height          =   495
  85.       Left            =   7260
  86.       TabIndex        =   20
  87.       Top             =   5640
  88.       Width           =   675
  89.    End
  90.    Begin CommandButton new_but 
  91.       Caption         =   "Ne&w"
  92.       Height          =   495
  93.       Left            =   4920
  94.       TabIndex        =   19
  95.       Top             =   5640
  96.       Width           =   675
  97.    End
  98.    Begin CommandButton save_but 
  99.       Caption         =   "&Save"
  100.       Height          =   495
  101.       Left            =   5700
  102.       TabIndex        =   18
  103.       Top             =   5640
  104.       Width           =   675
  105.    End
  106.    Begin CommandButton quit_but 
  107.       Caption         =   "&Quit"
  108.       Height          =   495
  109.       Left            =   8040
  110.       TabIndex        =   14
  111.       Top             =   5640
  112.       Width           =   675
  113.    End
  114.    Begin CommandButton prev_but 
  115.       Caption         =   "&Prev"
  116.       Height          =   495
  117.       Left            =   1800
  118.       TabIndex        =   13
  119.       Top             =   5640
  120.       Width           =   675
  121.    End
  122.    Begin TextBox notes_box 
  123.       FontBold        =   -1  'True
  124.       FontItalic      =   0   'False
  125.       FontName        =   "Arial"
  126.       FontSize        =   9.75
  127.       FontStrikethru  =   0   'False
  128.       FontUnderline   =   0   'False
  129.       Height          =   2715
  130.       Left            =   120
  131.       MultiLine       =   -1  'True
  132.       ScrollBars      =   2  'Vertical
  133.       TabIndex        =   10
  134.       Text            =   "Text1"
  135.       Top             =   1080
  136.       Width           =   3015
  137.    End
  138.    Begin TextBox adr5_box 
  139.       FontBold        =   -1  'True
  140.       FontItalic      =   0   'False
  141.       FontName        =   "Arial"
  142.       FontSize        =   12
  143.       FontStrikethru  =   0   'False
  144.       FontUnderline   =   0   'False
  145.       Height          =   420
  146.       Left            =   4740
  147.       TabIndex        =   7
  148.       Text            =   "Text1"
  149.       Top             =   3780
  150.       Width           =   3975
  151.    End
  152.    Begin TextBox adr4_box 
  153.       FontBold        =   -1  'True
  154.       FontItalic      =   0   'False
  155.       FontName        =   "Arial"
  156.       FontSize        =   12
  157.       FontStrikethru  =   0   'False
  158.       FontUnderline   =   0   'False
  159.       Height          =   420
  160.       Left            =   4740
  161.       TabIndex        =   6
  162.       Text            =   "Text1"
  163.       Top             =   3300
  164.       Width           =   3975
  165.    End
  166.    Begin TextBox fax_box 
  167.       FontBold        =   -1  'True
  168.       FontItalic      =   0   'False
  169.       FontName        =   "Arial"
  170.       FontSize        =   12
  171.       FontStrikethru  =   0   'False
  172.       FontUnderline   =   0   'False
  173.       Height          =   420
  174.       Left            =   4740
  175.       TabIndex        =   9
  176.       Text            =   "Text1"
  177.       Top             =   4740
  178.       Width           =   4035
  179.    End
  180.    Begin TextBox tel_box 
  181.       FontBold        =   -1  'True
  182.       FontItalic      =   0   'False
  183.       FontName        =   "Arial"
  184.       FontSize        =   12
  185.       FontStrikethru  =   0   'False
  186.       FontUnderline   =   0   'False
  187.       Height          =   420
  188.       Left            =   4740
  189.       TabIndex        =   8
  190.       Text            =   "Text5"
  191.       Top             =   4260
  192.       Width           =   4035
  193.    End
  194.    Begin TextBox adr3_box 
  195.       FontBold        =   -1  'True
  196.       FontItalic      =   0   'False
  197.       FontName        =   "Arial"
  198.       FontSize        =   12
  199.       FontStrikethru  =   0   'False
  200.       FontUnderline   =   0   'False
  201.       Height          =   420
  202.       Left            =   4740
  203.       TabIndex        =   5
  204.       Text            =   "Text4"
  205.       Top             =   2820
  206.       Width           =   3975
  207.    End
  208.    Begin TextBox adr2_box 
  209.       FontBold        =   -1  'True
  210.       FontItalic      =   0   'False
  211.       FontName        =   "Arial"
  212.       FontSize        =   12
  213.       FontStrikethru  =   0   'False
  214.       FontUnderline   =   0   'False
  215.       Height          =   420
  216.       Left            =   4740
  217.       TabIndex        =   4
  218.       Text            =   "Text3"
  219.       Top             =   2340
  220.       Width           =   3975
  221.    End
  222.    Begin TextBox adr1_box 
  223.       FontBold        =   -1  'True
  224.       FontItalic      =   0   'False
  225.       FontName        =   "Arial"
  226.       FontSize        =   12
  227.       FontStrikethru  =   0   'False
  228.       FontUnderline   =   0   'False
  229.       Height          =   420
  230.       Left            =   4740
  231.       TabIndex        =   3
  232.       Text            =   "Text2"
  233.       Top             =   1860
  234.       Width           =   3975
  235.    End
  236.    Begin TextBox surname_box 
  237.       FontBold        =   -1  'True
  238.       FontItalic      =   0   'False
  239.       FontName        =   "Arial"
  240.       FontSize        =   12
  241.       FontStrikethru  =   0   'False
  242.       FontUnderline   =   0   'False
  243.       Height          =   420
  244.       Left            =   4740
  245.       TabIndex        =   2
  246.       Text            =   "Text1"
  247.       Top             =   1380
  248.       Width           =   3975
  249.    End
  250.    Begin CommandButton find_but 
  251.       Caption         =   "&Find"
  252.       Height          =   495
  253.       Left            =   3360
  254.       TabIndex        =   12
  255.       Top             =   5640
  256.       Width           =   675
  257.    End
  258.    Begin CommandButton next_but 
  259.       Caption         =   "&Next"
  260.       Height          =   495
  261.       Left            =   1020
  262.       TabIndex        =   11
  263.       Top             =   5640
  264.       Width           =   675
  265.    End
  266.    Begin TextBox forename_box 
  267.       FontBold        =   -1  'True
  268.       FontItalic      =   0   'False
  269.       FontName        =   "Arial"
  270.       FontSize        =   12
  271.       FontStrikethru  =   0   'False
  272.       FontUnderline   =   0   'False
  273.       Height          =   420
  274.       Left            =   4740
  275.       TabIndex        =   1
  276.       Text            =   "Text1"
  277.       Top             =   900
  278.       Width           =   3975
  279.    End
  280.    Begin Label Label9 
  281.       Caption         =   "Address:"
  282.       FontBold        =   -1  'True
  283.       FontItalic      =   -1  'True
  284.       FontName        =   "Arial"
  285.       FontSize        =   12
  286.       FontStrikethru  =   0   'False
  287.       FontUnderline   =   0   'False
  288.       Height          =   375
  289.       Left            =   3300
  290.       TabIndex        =   31
  291.       Top             =   1920
  292.       Width           =   1335
  293.    End
  294.    Begin Label Label8 
  295.       Caption         =   "Forename:"
  296.       FontBold        =   -1  'True
  297.       FontItalic      =   -1  'True
  298.       FontName        =   "Arial"
  299.       FontSize        =   12
  300.       FontStrikethru  =   0   'False
  301.       FontUnderline   =   0   'False
  302.       Height          =   375
  303.       Left            =   3300
  304.       TabIndex        =   30
  305.       Top             =   960
  306.       Width           =   1275
  307.    End
  308.    Begin Label Label7 
  309.       Caption         =   "Surname:"
  310.       FontBold        =   -1  'True
  311.       FontItalic      =   -1  'True
  312.       FontName        =   "Arial"
  313.       FontSize        =   12
  314.       FontStrikethru  =   0   'False
  315.       FontUnderline   =   0   'False
  316.       Height          =   375
  317.       Left            =   3300
  318.       TabIndex        =   29
  319.       Top             =   1440
  320.       Width           =   1335
  321.    End
  322.    Begin Label Label6 
  323.       Caption         =   "Sort by:"
  324.       FontBold        =   -1  'True
  325.       FontItalic      =   -1  'True
  326.       FontName        =   "Arial"
  327.       FontSize        =   12
  328.       FontStrikethru  =   0   'False
  329.       FontUnderline   =   0   'False
  330.       Height          =   375
  331.       Left            =   120
  332.       TabIndex        =   25
  333.       Top             =   3960
  334.       Width           =   1275
  335.    End
  336.    Begin Label Label5 
  337.       Caption         =   "Postcode:"
  338.       FontBold        =   -1  'True
  339.       FontItalic      =   -1  'True
  340.       FontName        =   "Arial"
  341.       FontSize        =   12
  342.       FontStrikethru  =   0   'False
  343.       FontUnderline   =   0   'False
  344.       Height          =   375
  345.       Left            =   3300
  346.       TabIndex        =   22
  347.       Top             =   3780
  348.       Width           =   1395
  349.    End
  350.    Begin Label Label4 
  351.       Caption         =   "Notes:"
  352.       FontBold        =   -1  'True
  353.       FontItalic      =   -1  'True
  354.       FontName        =   "Arial"
  355.       FontSize        =   12
  356.       FontStrikethru  =   0   'False
  357.       FontUnderline   =   0   'False
  358.       Height          =   375
  359.       Left            =   120
  360.       TabIndex        =   17
  361.       Top             =   720
  362.       Width           =   1215
  363.    End
  364.    Begin Label Label3 
  365.       Caption         =   "Fax:"
  366.       FontBold        =   -1  'True
  367.       FontItalic      =   -1  'True
  368.       FontName        =   "Arial"
  369.       FontSize        =   12
  370.       FontStrikethru  =   0   'False
  371.       FontUnderline   =   0   'False
  372.       Height          =   255
  373.       Left            =   3300
  374.       TabIndex        =   16
  375.       Top             =   4800
  376.       Width           =   1335
  377.    End
  378.    Begin Label Label2 
  379.       Caption         =   "Telephone:"
  380.       FontBold        =   -1  'True
  381.       FontItalic      =   -1  'True
  382.       FontName        =   "Arial"
  383.       FontSize        =   12
  384.       FontStrikethru  =   0   'False
  385.       FontUnderline   =   0   'False
  386.       Height          =   255
  387.       Left            =   3300
  388.       TabIndex        =   15
  389.       Top             =   4320
  390.       Width           =   1335
  391.    End
  392.    Begin Label Label1 
  393.       Alignment       =   2  'Center
  394.       Caption         =   "Address Book"
  395.       FontBold        =   -1  'True
  396.       FontItalic      =   0   'False
  397.       FontName        =   "Arial"
  398.       FontSize        =   24
  399.       FontStrikethru  =   0   'False
  400.       FontUnderline   =   0   'False
  401.       Height          =   495
  402.       Left            =   0
  403.       TabIndex        =   0
  404.       Top             =   120
  405.       Width           =   8895
  406.    End
  407. End
  408.  
  409.  
  410. Sub action_check_click ()
  411. Rem this sets filter to only addresses
  412. Rem with action outstanding
  413.  
  414. Rem check for changed details before moving
  415. Rem to another record
  416.  
  417. ' If you set a check box value in code, it triggers the click
  418. ' event. This is a good way to get infinite loops, and I don't
  419. ' like this effect! Therefore I've set a flag so that
  420. ' I can ignore unwanted click events.
  421.  
  422. If ignore_click = 1 Then
  423. ignore_click = 0
  424. Exit Sub
  425. End If
  426.  
  427. curr_rec = adr_ds!recnum
  428.  
  429. If chk_change() = "Cancel" Then
  430.  
  431.  
  432. ' reset check box without triggering code
  433.  
  434. ignore_click = 1
  435. If action_check.Value = 1 Then
  436. action_check.Value = 0
  437. Else
  438. action_check.Value = 1
  439. End If
  440.  
  441. Exit Sub
  442. End If
  443.  
  444. If action_check.Value Then
  445. Rem set filter
  446.  
  447. filt_adr
  448.  
  449.     If Not action_check.Value Then
  450.     ' it was changed back by filt_adr because no records exist
  451.     ' with the action field true
  452.     ' so restore current record
  453.  
  454.     criteria = "recnum = " + Str(curr_rec)
  455.     adr_ds.FindFirst criteria
  456.     
  457.     End If
  458.  
  459. Else
  460.  
  461. refresh_sql
  462.     
  463. criteria = "recnum = " + Str(curr_rec)
  464. adr_ds.FindFirst criteria
  465.  
  466. End If
  467.  
  468. upd_fields
  469.  
  470. End Sub
  471.  
  472. Sub Action_needed_Click ()
  473.  
  474. If newflag Then
  475. ' if a new record is current, we cannot
  476. ' update the dynaset yet
  477. Exit Sub
  478. End If
  479.  
  480.  
  481. adr_ds.Edit
  482.     
  483.     If action_needed.Value Then
  484.     adr_ds("ACTION") = True
  485.     Else
  486.     adr_ds("ACTION") = False
  487.     End If
  488.  
  489. adr_ds.Update
  490.  
  491. If action_check.Value = 1 Then
  492. Rem if we are presenting only records which have the action flag set,
  493. Rem then we need to update the SQL
  494.  
  495. filt_adr
  496.  
  497. End If
  498.  
  499. upd_fields
  500.  
  501. End Sub
  502.  
  503. Sub del_but_Click ()
  504.  
  505. Dim decis As Integer
  506.  
  507. decis = MsgBox("Really delete record?", 4)
  508.  
  509. If decis = 6 Then
  510. adr_ds.Delete
  511.  
  512.     adr_ds.MovePrevious
  513.  
  514.     If adr_ds.BOF Then
  515.     adr_ds.MoveFirst
  516.     End If
  517.  
  518.     upd_fields
  519.     
  520. End If
  521.  
  522. End Sub
  523.  
  524. Sub edit_but_Click ()
  525. adr_ds.Edit
  526. End Sub
  527.  
  528. Sub find_but_Click ()
  529.  
  530. If chk_change() = "Cancel" Then
  531. Exit Sub
  532. End If
  533.  
  534. Dim rec_to_find As String, curr_rec As String, quotetest As Integer
  535. curr_rec = adr_ds.Bookmark
  536.  
  537. If curr_ind = "address5" Then
  538. rec_to_find = InputBox$("Enter a post code", "Find a record")
  539. criteria = "ucase$(address5) >= " + "'" + UCase$(rec_to_find) + "'"
  540.  
  541. Else
  542. rec_to_find = InputBox$("Enter a surname", "Find a record")
  543.  
  544. criteria = "ucase$(Surname) >= " + "'" + UCase$(rec_to_find) + "'"
  545.  
  546. End If
  547.  
  548. ' test for empty string
  549.     If rec_to_find = "" Then
  550.     Exit Sub
  551.     End If
  552.  
  553. ' If user typed in a single quote, this causes a crash!
  554. ' Therefore, check first
  555.  
  556.  
  557.     quotetest = InStr(rec_to_find, "'")
  558.  
  559.     If quotetest Then
  560.     MsgBox ("Can't search for value including single quote")
  561.     Exit Sub
  562.     End If
  563.  
  564. adr_ds.FindFirst criteria
  565.  
  566. If adr_ds.NoMatch Then
  567. MsgBox ("Not found")
  568. adr_ds.Bookmark = curr_rec
  569. End If
  570.  
  571.     
  572.  
  573. upd_fields
  574.  
  575. End Sub
  576.  
  577. Sub first_but_Click ()
  578.  
  579. If chk_change() = "Cancel" Then
  580. Exit Sub
  581. End If
  582.  
  583. adr_ds.MoveFirst
  584.  
  585. upd_fields
  586.  
  587. End Sub
  588.  
  589. Sub last_but_Click ()
  590.  
  591. If chk_change() = "Cancel" Then
  592. Exit Sub
  593. End If
  594.  
  595. adr_ds.MoveLast
  596.  
  597. upd_fields
  598.  
  599. End Sub
  600.  
  601. Sub list_but_Click ()
  602.  
  603. curr_rec = adr_ds!recnum
  604.  
  605. If chk_change() = "Cancel" Then
  606. Exit Sub
  607. End If
  608.  
  609. If first_list = 1 Then
  610. first_list = 0
  611. Rem refresh list if first time
  612.  
  613. 'It would be nice to refresh list automatically each
  614. 'time, but it takes sooooo long it seems better not
  615. 'to do it...
  616.  
  617. upd_list
  618. End If
  619.  
  620. list_form.Show
  621.  
  622. End Sub
  623.  
  624. Sub new_but_Click ()
  625. adr_ds.AddNew
  626. newflag = -1
  627. Dim countsnap As snapshot
  628. Dim newnum As Long
  629.  
  630. ' Now find unique number for recnum field
  631.  
  632. sql_stmnt = "Select max ([recnum]) as maxrec from address"
  633.  
  634. Set countsnap = adr_db.CreateSnapshot(sql_stmnt)
  635.  
  636. countsnap.MoveFirst
  637. newnum = countsnap!maxrec
  638. newnum = newnum + 1
  639.  
  640. ' assign new number to recnum
  641. adr_ds!recnum = newnum
  642.  
  643. upd_fields
  644. End Sub
  645.  
  646. Sub next_but_Click ()
  647.  
  648. If chk_change() = "Cancel" Then
  649. Exit Sub
  650. End If
  651.  
  652. adr_ds.MoveNext
  653.  
  654. If Not adr_ds.EOF Then
  655. upd_fields
  656. Else
  657. MsgBox ("No more addresses")
  658. adr_ds.MoveLast
  659. upd_fields
  660. End If
  661.  
  662.  
  663. End Sub
  664.  
  665. Sub notes_box_LostFocus ()
  666.  
  667. If newflag Then
  668. ' can't update dynaset if new record
  669. Exit Sub
  670. End If
  671.  
  672. adr_ds.Edit
  673. adr_ds("NOTES") = notes_box.Text
  674. adr_ds.Update
  675.  
  676. End Sub
  677.  
  678. Sub order_option_Click (Index As Integer)
  679.  
  680. Dim decis As Integer
  681.  
  682. curr_rec = adr_ds!recnum
  683.  
  684. If chk_change() = "Cancel" Then
  685. Exit Sub
  686. End If
  687.  
  688. Select Case Index
  689.  
  690. Case 0
  691.  
  692. curr_ind = "address5"
  693. ' address5 is the name of the postcode field
  694.  
  695. Case 1
  696.  
  697. curr_ind = "surname"
  698.  
  699. End Select
  700.  
  701. refresh_sql
  702.  
  703. criteria = "recnum = " + Str(curr_rec)
  704.  
  705. adr_ds.FindFirst criteria
  706.  
  707. upd_fields
  708.  
  709. End Sub
  710.  
  711. Sub pack_but_Click ()
  712.  
  713. If chk_change() = "Cancel" Then
  714. Exit Sub
  715. End If
  716.  
  717. screen.MousePointer = 11
  718.  
  719. Dim adr_tb As table
  720. Dim oldtd As tabledef
  721. Dim newtb As table
  722. Dim newtd As New tabledef
  723. Dim newix As New Index
  724.  
  725.  
  726. Dim fieldcount As Integer
  727.  
  728. curr_rec = adr_ds!recnum
  729.  
  730. Rem close the dynaset
  731. adr_ds.Close
  732.  
  733. Set adr_tb = adr_db.OpenTable("ADDRESS")
  734. Rem open the address table
  735.  
  736. Set oldtd = adr_db.TableDefs("ADDRESS")
  737.  
  738. Rem define fields
  739. fieldcount = oldtd.Fields.Count - 1
  740.  
  741. ReDim newfields(fieldcount) As New field
  742.  
  743. Dim countvar As Integer
  744.  
  745. For countvar = 0 To fieldcount
  746.  
  747. newfields(countvar).Name = oldtd.Fields(countvar).Name
  748. newfields(countvar).Type = oldtd.Fields(countvar).Type
  749. newfields(countvar).Size = oldtd.Fields(countvar).Size
  750.  
  751.  
  752. Next
  753.  
  754. Rem now build new tabledef
  755.  
  756. newtd.Name = "NEWTABLE"
  757.                                        
  758. Rem add fields
  759.  
  760. For countvar = 0 To fieldcount
  761.  
  762. newtd.Fields.Append newfields(countvar)
  763.  
  764. Next
  765.  
  766. Rem append new table to database
  767.  
  768. adr_db.TableDefs.Append newtd
  769.  
  770. Rem open new table
  771.  
  772. Set newtb = adr_db.OpenTable("NEWTABLE")
  773.  
  774.  
  775. Rem copy records from old to new
  776.  
  777. Rem set order to
  778.  
  779. adr_tb.Index = ""
  780.  
  781. adr_tb.MoveFirst
  782.  
  783. sql_stmnt = "insert into newtable select * from address"
  784.  
  785. adr_db.Execute sql_stmnt
  786.  
  787. Rem now duplicate indexes
  788.  
  789. indexcount = oldtd.Indexes.Count - 1
  790.  
  791. ReDim newindexes(indexcount) As New Index
  792.  
  793. For countvar = 0 To indexcount
  794. newindexes(countvar).Fields = oldtd.Indexes(countvar).Fields
  795. newindexes(countvar).Name = oldtd.Indexes(countvar).Name
  796. newindexes(countvar).Unique = oldtd.Indexes(countvar).Unique
  797. newindexes(countvar).Primary = oldtd.Indexes(countvar).Primary
  798. Next
  799.  
  800. Rem add indexes
  801.  
  802. newtb.Close
  803. Rem must close table before indexing
  804.  
  805. For countvar = 0 To indexcount
  806. newtd.Indexes.Append newindexes(countvar)
  807. Next
  808.  
  809. Rem delete and rename
  810.  
  811. adr_tb.Close
  812. adr_db.Close
  813.  
  814. Kill "C:\ADR\ADDRESS.DBF"
  815. Kill "C:\ADR\ADDRESS.FPT"
  816. Kill "C:\ADR\ADDRESS.CDX"
  817.  
  818. Name "C:\ADR\NEWTABLE.DBF" As "C:\ADR\ADDRESS.DBF"
  819. Name "C:\ADR\NEWTABLE.FPT" As "C:\ADR\ADDRESS.FPT"
  820. Name "C:\ADR\NEWTABLE.CDX" As "C:\ADR\ADDRESS.CDX"
  821.  
  822.  
  823. Rem reopen database and table
  824.  
  825. Set adr_db = OpenDatabase("C:\ADR", False, False, "FoxPro 2.5;")
  826.  
  827. ' Restore dynaset
  828.  
  829. refresh_sql
  830.  
  831. ' restore current record
  832.  
  833. criteria = "recnum = " + Str(curr_rec)
  834.  
  835. adr_ds.FindFirst criteria
  836.  
  837. upd_fields
  838.  
  839. screen.MousePointer = 0
  840.  
  841. MsgBox ("Pack completed")
  842.  
  843. End Sub
  844.  
  845. Sub prev_but_Click ()
  846.  
  847. If chk_change() = "Cancel" Then
  848. Exit Sub
  849. End If
  850.  
  851. adr_ds.MovePrevious
  852.  
  853. If Not adr_ds.BOF Then
  854. upd_fields
  855. Else
  856. MsgBox ("No previous addresses")
  857. adr_ds.MoveFirst
  858. upd_fields
  859. End If
  860.  
  861.  
  862. End Sub
  863.  
  864. Sub quit_but_Click ()
  865.  
  866. If chk_change() = "Cancel" Then
  867. Exit Sub
  868. End If
  869.  
  870. End
  871.  
  872. End Sub
  873.  
  874. Sub save_but_Click ()
  875.  
  876. save_rec
  877.  
  878. End Sub
  879.  
  880.