home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form fReplace
- Caption = "Record Replace"
- Height = 3795
- Icon = REPLACE.FRX:0000
- Left = 3570
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MDIChild = -1 'True
- ScaleHeight = 3372
- ScaleMode = 0 'User
- ScaleWidth = 5184
- Top = 2505
- Width = 5280
- Begin ListBox cTableList
- Height = 1590
- Left = 240
- Sorted = -1 'True
- TabIndex = 9
- Top = 360
- Width = 2280
- End
- Begin ListBox cFieldList
- Height = 1590
- Left = 2625
- Sorted = -1 'True
- TabIndex = 0
- Top = 360
- Width = 2280
- End
- Begin TextBox cReplaceWith
- Height = 290
- Left = 1672
- TabIndex = 5
- Top = 2051
- Width = 3237
- End
- Begin TextBox cCondition
- Height = 290
- Left = 1672
- TabIndex = 7
- Top = 2413
- Width = 3237
- End
- Begin CommandButton OkayButton
- Caption = "&OK"
- Default = -1 'True
- Enabled = 0 'False
- Height = 374
- Left = 597
- TabIndex = 3
- Top = 2895
- Width = 1684
- End
- Begin CommandButton CancelButton
- Cancel = -1 'True
- Caption = "&Close"
- Height = 374
- Left = 2867
- TabIndex = 4
- Top = 2895
- Width = 1684
- End
- Begin Label TableListLabel
- Caption = "Table List:"
- Height = 253
- Left = 239
- TabIndex = 8
- Top = 121
- Width = 1206
- End
- Begin Label ConditionLabel
- Caption = "Condition:"
- Height = 253
- Left = 239
- TabIndex = 6
- Top = 2413
- Width = 1445
- End
- Begin Label ReplaceWithLabel
- Caption = "Replace With:"
- Height = 253
- Left = 239
- TabIndex = 2
- Top = 2051
- Width = 1445
- End
- Begin Label FieldListLabel
- Caption = "Field List:"
- Height = 253
- Left = 2628
- TabIndex = 1
- Top = 121
- Width = 1206
- End
- Option Explicit
- Sub CancelButton_Click ()
- Unload Me
- End Sub
- Sub cFieldList_Click ()
- If cFieldList <> "" And cReplaceWith <> "" Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cReplaceWith_Change ()
- If cFieldList <> "" And cReplaceWith <> "" Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cTableList_Click ()
- Dim i As Integer
- cFieldList.Clear
- gCurrentDB.TableDefs(cTableList).Fields.Refresh
- For i = 0 To gCurrentDB.TableDefs(cTableList).Fields.Count - 1
- cFieldList.AddItem gCurrentDB.TableDefs(cTableList).Fields(i).Name
- Next
- End Sub
- Sub Form_Load ()
- Height = 3792
- Width = 5280
- End Sub
- Sub OkayButton_Click ()
- Dim rp As String 'replace with string
- Dim wh As String 'where condition
- Dim r As Long 'return from execute sql
- On Error GoTo ReplaceErr
- MsgBar "Replacing Records", True
- If gCurrentDB.TableDefs(cTableList).Fields(cFieldList).Type = FT_STRING Then
- rp = "'" + cReplaceWith + "'"
- Else
- rp = cReplaceWith
- End If
- If cCondition = "" Then
- wh = ""
- Else
- wh = "where " + cCondition
- End If
- r = gCurrentDB.ExecuteSQL("update " + cTableList + " set " + cFieldList + "=" + rp + wh)
- If r > 0 Then
- If gfTransPending Then gfDBChanged = True
- End If
- Unload Me
- GoTo ReplaceEnd
- ReplaceErr:
- ShowError
- Resume ReplaceEnd
- ReplaceEnd:
- MsgBar "", False
- End Sub
-