home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / VISDATA / REPLACE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-12  |  5.6 KB  |  188 lines

  1. VERSION 5.00
  2. Begin VB.Form frmReplace 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "
  5.    ClientHeight    =   3855
  6.    ClientLeft      =   1860
  7.    ClientTop       =   2070
  8.    ClientWidth     =   5175
  9.    HelpContextID   =   2016091
  10.    Icon            =   "REPLACE.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3421.786
  16.    ScaleMode       =   0  'User
  17.    ScaleWidth      =   5081.244
  18.    ShowInTaskbar   =   0   'False
  19.    StartUpPosition =   1  'CenterOwner
  20.    Begin VB.ListBox lstTables 
  21.       BackColor       =   &H00FFFFFF&
  22.       Height          =   1530
  23.       Left            =   240
  24.       Sorted          =   -1  'True
  25.       TabIndex        =   1
  26.       Top             =   360
  27.       Width           =   2295
  28.    End
  29.    Begin VB.ListBox lstFields 
  30.       BackColor       =   &H00FFFFFF&
  31.       Height          =   1530
  32.       Left            =   2640
  33.       Sorted          =   -1  'True
  34.       TabIndex        =   3
  35.       Top             =   360
  36.       Width           =   2295
  37.    End
  38.    Begin VB.TextBox txtReplaceWith 
  39.       BackColor       =   &H00FFFFFF&
  40.       Height          =   285
  41.       Left            =   240
  42.       TabIndex        =   5
  43.       Top             =   2280
  44.       Width           =   4695
  45.    End
  46.    Begin VB.TextBox txtCondition 
  47.       BackColor       =   &H00FFFFFF&
  48.       Height          =   285
  49.       Left            =   240
  50.       TabIndex        =   7
  51.       Top             =   2880
  52.       Width           =   4695
  53.    End
  54.    Begin VB.CommandButton cmdOK 
  55.       Caption         =   "
  56. (&O)"
  57.       Default         =   -1  'True
  58.       Enabled         =   0   'False
  59.       Height          =   375
  60.       Left            =   480
  61.       MaskColor       =   &H00000000&
  62.       TabIndex        =   8
  63.       Top             =   3360
  64.       Width           =   2055
  65.    End
  66.    Begin VB.CommandButton cmdCancel 
  67.       Cancel          =   -1  'True
  68.       Caption         =   "
  69. (&C)"
  70.       Height          =   375
  71.       Left            =   2640
  72.       MaskColor       =   &H00000000&
  73.       TabIndex        =   9
  74.       Top             =   3360
  75.       Width           =   2055
  76.    End
  77.    Begin VB.Label lblLabels 
  78.       AutoSize        =   -1  'True
  79.       Caption         =   "
  80.       Height          =   195
  81.       Index           =   0
  82.       Left            =   240
  83.       TabIndex        =   0
  84.       Top             =   120
  85.       Width           =   450
  86.    End
  87.    Begin VB.Label lblLabels 
  88.       AutoSize        =   -1  'True
  89.       Caption         =   "
  90.       Height          =   195
  91.       Index           =   3
  92.       Left            =   240
  93.       TabIndex        =   6
  94.       Top             =   2640
  95.       Width           =   585
  96.    End
  97.    Begin VB.Label lblLabels 
  98.       AutoSize        =   -1  'True
  99.       Caption         =   "
  100.       Height          =   195
  101.       Index           =   2
  102.       Left            =   240
  103.       TabIndex        =   4
  104.       Top             =   2040
  105.       Width           =   1005
  106.    End
  107.    Begin VB.Label lblLabels 
  108.       AutoSize        =   -1  'True
  109.       Caption         =   "
  110.       Height          =   195
  111.       Index           =   1
  112.       Left            =   2640
  113.       TabIndex        =   2
  114.       Top             =   120
  115.       Width           =   390
  116.    End
  117. Attribute VB_Name = "frmReplace"
  118. Attribute VB_GlobalNameSpace = False
  119. Attribute VB_Creatable = False
  120. Attribute VB_PredeclaredId = True
  121. Attribute VB_Exposed = False
  122. Option Explicit
  123. '>>>>>>>>>>>>>>>>>>>>>>>>
  124. Const FORMCAPTION = "
  125. Const BUTTON1 = "
  126. (&O)"
  127. Const BUTTON2 = "
  128. (&C)"
  129. Const Label1 = "
  130. Const Label2 = "
  131. Const LABEL3 = "
  132. Const LABEL4 = "
  133. Const MSG1 = "
  134. '>>>>>>>>>>>>>>>>>>>>>>>>
  135. Private Sub cmdCancel_Click()
  136.   Unload Me
  137. End Sub
  138. Private Sub lstFields_Click()
  139.   cmdOK.Enabled = Len(lstFields.Text) > 0 And Len(txtReplaceWith.Text) > 0
  140. End Sub
  141. Private Sub txtReplaceWith_Change()
  142.   cmdOK.Enabled = Len(lstFields.Text) > 0 And Len(txtReplaceWith.Text) > 0
  143. End Sub
  144. Private Sub lstTables_Click()
  145.   Dim i As Integer
  146.   Dim fld As Field
  147.   ListItemNames gdbCurrentDB.TableDefs(StripConnect(lstTables.Text)).Fields, lstFields, True
  148. End Sub
  149. Private Sub Form_Load()
  150.   Me.Caption = FORMCAPTION
  151.   cmdOK.Caption = BUTTON1
  152.   cmdCancel.Caption = BUTTON2
  153.   lblLabels(0).Caption = Label1
  154.   lblLabels(1).Caption = Label2
  155.   lblLabels(2).Caption = LABEL3
  156.   lblLabels(3).Caption = LABEL4
  157.   RefreshTables frmReplace.lstTables
  158. End Sub
  159. Private Sub cmdOK_Click()
  160.   Dim sReplaceTxt As String       '
  161.   Dim sWhereCondition As String   'where 
  162.   On Error GoTo ReplaceErr
  163.   MsgBar MSG1, True
  164.   If gdbCurrentDB.TableDefs(StripConnect(lstTables.Text)).Fields(lstFields).Type = dbText Then
  165.     sReplaceTxt = "'" & txtReplaceWith & "'"
  166.   Else
  167.     sReplaceTxt = txtReplaceWith
  168.   End If
  169.   If Len(txtCondition.Text) = 0 Then
  170.     sWhereCondition = vbNullString
  171.   Else
  172.     sWhereCondition = " where " & txtCondition
  173.   End If
  174.   If gsDataType = gsSQLDB Then
  175.     gdbCurrentDB.Execute "update " & StripConnect(lstTables.Text) & " set " & lstFields.Text & "=" & sReplaceTxt & sWhereCondition, dbSQLPassThrough
  176.   Else
  177.     gdbCurrentDB.Execute "update " & StripConnect(lstTables.Text) & " set [" & lstFields.Text & "]=" & sReplaceTxt & sWhereCondition
  178.   End If
  179.   If gdbCurrentDB.RecordsAffected > 0 Then
  180.     If gbTransPending Then gbDBChanged = True
  181.   End If
  182.   Unload Me
  183.   MsgBar vbNullString, False
  184.   Exit Sub
  185. ReplaceErr:
  186.   ShowError
  187. End Sub
  188.