home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / replace.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  5.2 KB  |  175 lines

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