home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l406 / 4.ddi / REPLACE.FR_ / REPLACE.bin (.txt)
Encoding:
Visual Basic Form  |  1992-10-21  |  4.2 KB  |  154 lines

  1. VERSION 2.00
  2. Begin Form fReplace 
  3.    Caption         =   "Record Replace"
  4.    Height          =   3795
  5.    Icon            =   REPLACE.FRX:0000
  6.    Left            =   3570
  7.    LinkTopic       =   "Form1"
  8.    MaxButton       =   0   'False
  9.    MDIChild        =   -1  'True
  10.    ScaleHeight     =   3372
  11.    ScaleMode       =   0  'User
  12.    ScaleWidth      =   5184
  13.    Top             =   2505
  14.    Width           =   5280
  15.    Begin ListBox cTableList 
  16.       Height          =   1590
  17.       Left            =   240
  18.       Sorted          =   -1  'True
  19.       TabIndex        =   9
  20.       Top             =   360
  21.       Width           =   2280
  22.    End
  23.    Begin ListBox cFieldList 
  24.       Height          =   1590
  25.       Left            =   2625
  26.       Sorted          =   -1  'True
  27.       TabIndex        =   0
  28.       Top             =   360
  29.       Width           =   2280
  30.    End
  31.    Begin TextBox cReplaceWith 
  32.       Height          =   290
  33.       Left            =   1672
  34.       TabIndex        =   5
  35.       Top             =   2051
  36.       Width           =   3237
  37.    End
  38.    Begin TextBox cCondition 
  39.       Height          =   290
  40.       Left            =   1672
  41.       TabIndex        =   7
  42.       Top             =   2413
  43.       Width           =   3237
  44.    End
  45.    Begin CommandButton OkayButton 
  46.       Caption         =   "&OK"
  47.       Default         =   -1  'True
  48.       Enabled         =   0   'False
  49.       Height          =   374
  50.       Left            =   597
  51.       TabIndex        =   3
  52.       Top             =   2895
  53.       Width           =   1684
  54.    End
  55.    Begin CommandButton CancelButton 
  56.       Cancel          =   -1  'True
  57.       Caption         =   "&Close"
  58.       Height          =   374
  59.       Left            =   2867
  60.       TabIndex        =   4
  61.       Top             =   2895
  62.       Width           =   1684
  63.    End
  64.    Begin Label TableListLabel 
  65.       Caption         =   "Table List:"
  66.       Height          =   253
  67.       Left            =   239
  68.       TabIndex        =   8
  69.       Top             =   121
  70.       Width           =   1206
  71.    End
  72.    Begin Label ConditionLabel 
  73.       Caption         =   "Condition:"
  74.       Height          =   253
  75.       Left            =   239
  76.       TabIndex        =   6
  77.       Top             =   2413
  78.       Width           =   1445
  79.    End
  80.    Begin Label ReplaceWithLabel 
  81.       Caption         =   "Replace With:"
  82.       Height          =   253
  83.       Left            =   239
  84.       TabIndex        =   2
  85.       Top             =   2051
  86.       Width           =   1445
  87.    End
  88.    Begin Label FieldListLabel 
  89.       Caption         =   "Field List:"
  90.       Height          =   253
  91.       Left            =   2628
  92.       TabIndex        =   1
  93.       Top             =   121
  94.       Width           =   1206
  95.    End
  96. Option Explicit
  97. Sub CancelButton_Click ()
  98.   Unload Me
  99. End Sub
  100. Sub cFieldList_Click ()
  101.   If cFieldList <> "" And cReplaceWith <> "" Then
  102.     OkayButton.Enabled = True
  103.   Else
  104.     OkayButton.Enabled = False
  105.   End If
  106. End Sub
  107. Sub cReplaceWith_Change ()
  108.   If cFieldList <> "" And cReplaceWith <> "" Then
  109.     OkayButton.Enabled = True
  110.   Else
  111.     OkayButton.Enabled = False
  112.   End If
  113. End Sub
  114. Sub cTableList_Click ()
  115.   Dim i As Integer
  116.   cFieldList.Clear
  117.   gCurrentDB.TableDefs(cTableList).Fields.Refresh
  118.   For i = 0 To gCurrentDB.TableDefs(cTableList).Fields.Count - 1
  119.     cFieldList.AddItem gCurrentDB.TableDefs(cTableList).Fields(i).Name
  120.   Next
  121. End Sub
  122. Sub Form_Load ()
  123.   Height = 3792
  124.   Width = 5280
  125. End Sub
  126. Sub OkayButton_Click ()
  127.   Dim rp As String      'replace with string
  128.   Dim wh As String      'where condition
  129.   Dim r As Long         'return from execute sql
  130.   On Error GoTo ReplaceErr
  131.   MsgBar "Replacing Records", True
  132.   If gCurrentDB.TableDefs(cTableList).Fields(cFieldList).Type = FT_STRING Then
  133.     rp = "'" + cReplaceWith + "'"
  134.   Else
  135.     rp = cReplaceWith
  136.   End If
  137.   If cCondition = "" Then
  138.     wh = ""
  139.   Else
  140.     wh = "where " + cCondition
  141.   End If
  142.   r = gCurrentDB.ExecuteSQL("update " + cTableList + " set " + cFieldList + "=" + rp + wh)
  143.   If r > 0 Then
  144.     If gfTransPending Then gfDBChanged = True
  145.   End If
  146.   Unload Me
  147.   GoTo ReplaceEnd
  148. ReplaceErr:
  149.   ShowError
  150.   Resume ReplaceEnd
  151. ReplaceEnd:
  152.   MsgBar "", False
  153. End Sub
  154.