home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmReplace
- BorderStyle = 3 'Fixed Double
- Caption = "Global Replace"
- ClientHeight = 3855
- ClientLeft = 1860
- ClientTop = 2070
- ClientWidth = 5175
- Height = 4260
- HelpContextID = 2016091
- Icon = "REPLACE.frx":0000
- Left = 1800
- LinkTopic = "Form1"
- LockControls = -1 'True
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3834.531
- ScaleMode = 0 'User
- ScaleWidth = 5199.07
- Top = 1725
- Width = 5295
- Begin VB.ListBox lstTables
- BackColor = &H00FFFFFF&
- Height = 1590
- Left = 240
- Sorted = -1 'True
- TabIndex = 9
- Top = 360
- Width = 2295
- End
- Begin VB.ListBox lstFields
- BackColor = &H00FFFFFF&
- Height = 1590
- Left = 2640
- Sorted = -1 'True
- TabIndex = 0
- Top = 360
- Width = 2295
- End
- Begin VB.TextBox txtReplaceWith
- BackColor = &H00FFFFFF&
- Height = 285
- Left = 240
- TabIndex = 5
- Top = 2280
- Width = 4695
- End
- Begin VB.TextBox txtCondition
- BackColor = &H00FFFFFF&
- Height = 285
- Left = 240
- TabIndex = 7
- Top = 2880
- Width = 4695
- End
- Begin VB.CommandButton cmdOK
- Caption = "&OK"
- Default = -1 'True
- Enabled = 0 'False
- Height = 375
- Left = 480
- TabIndex = 3
- Top = 3360
- Width = 2055
- End
- Begin VB.CommandButton cmdCancel
- Cancel = -1 'True
- Caption = "&Close"
- Height = 375
- Left = 2640
- TabIndex = 4
- Top = 3360
- Width = 2055
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "Table:"
- Height = 195
- Index = 0
- Left = 240
- TabIndex = 8
- Top = 120
- Width = 450
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "Criteria:"
- Height = 195
- Index = 1
- Left = 240
- TabIndex = 6
- Top = 2640
- Width = 525
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "Replace With:"
- Height = 195
- Index = 2
- Left = 240
- TabIndex = 2
- Top = 2040
- Width = 1110
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "Field:"
- Height = 195
- Index = 3
- Left = 2640
- TabIndex = 1
- Top = 120
- Width = 375
- End
- Attribute VB_Name = "frmReplace"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub cmdCancel_Click()
- Unload Me
- End Sub
- Private Sub lstFields_Click()
- If Len(lstFields.Text) > 0 And Len(txtReplaceWith.Text) > 0 Then
- cmdOK.Enabled = True
- Else
- cmdOK.Enabled = False
- End If
- End Sub
- Private Sub txtReplaceWith_Change()
- If Len(lstFields.Text) > 0 And Len(txtReplaceWith.Text) > 0 Then
- cmdOK.Enabled = True
- Else
- cmdOK.Enabled = False
- End If
- End Sub
- Private Sub lstTables_Click()
- Dim i As Integer
- Dim fld As Field
- ListItemNames gdbCurrentDB.TableDefs(StripConnect(lstTables.Text)).Fields, lstFields, True
- End Sub
- Private Sub Form_Load()
- CenterMe Me, gnMDIFORM
- RefreshTables frmReplace.lstTables, False
- End Sub
- Private Sub cmdOK_Click()
- Dim sReplaceTxt As String 'replace with string
- Dim sWhereCondition As String 'where condition
- On Error GoTo ReplaceErr
- MsgBar "Replacing Records", True
- If gdbCurrentDB.TableDefs(StripConnect(lstTables.Text)).Fields(lstFields).Type = dbText Then
- sReplaceTxt = "'" & txtReplaceWith & "'"
- Else
- sReplaceTxt = txtReplaceWith
- End If
- If Len(txtCondition.Text) = 0 Then
- sWhereCondition = gsNULL_STR
- Else
- sWhereCondition = " where " & txtCondition
- End If
- If gsDataType = gsSQLDB Then
- gdbCurrentDB.Execute "update " & StripConnect(lstTables.Text) & " set " & lstFields.Text & "=" & sReplaceTxt & sWhereCondition, dbSQLPassThrough
- Else
- gdbCurrentDB.Execute "update " & StripConnect(lstTables.Text) & " set [" & lstFields.Text & "]=" & sReplaceTxt & sWhereCondition
- End If
- If gdbCurrentDB.RecordsAffected > 0 Then
- If gbTransPending Then gbDBChanged = True
- End If
- Unload Me
- MsgBar gsNULL_STR, False
- Exit Sub
- ReplaceErr:
- ShowError
- Exit Sub
- End Sub
-